Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows ? #2

Open
huqedato opened this issue Nov 30, 2023 · 3 comments
Open

Windows ? #2

huqedato opened this issue Nov 30, 2023 · 3 comments

Comments

@huqedato
Copy link

huqedato commented Nov 30, 2023

Hi,

Great to have a Windows version... Powershell.

Thanks.

@iamandrewluca
Copy link

Contributions are welcome.

@xthezealot
Copy link
Owner

xthezealot commented Dec 5, 2023

Exactly!

And you can use this code as a foundation (made by GPT-4, not tested):

$TARGET_DIR = "node_modules"

if (-Not (Test-Path $TARGET_DIR)) {
    Write-Host "$TARGET_DIR does not exist"
    exit 1
}

$PATTERNS = @(
    "__tests__", "_config.yml", ".*ignore", ".babel*", ".circle*", ".documentup*", ".ds_store", ".editorconfig",
    ".env*", ".git*", ".idea", ".lint*", ".npm*", ".nyc*", ".prettier*", ".tern-project", ".yarn-integrity",
    ".yarn-metadata.json", ".yarnclean", ".yo-*", "*.coffee", "*.flow*", "*.jst", "*.markdown", "*.md", "*.mkd", "*.swp", 
    "*.tgz", "*appveyor*", "*coveralls*", "*eslint*", "*htmllint*", "*jshint*", "*readme*", "*stylelint*", "*travis*", 
    "*tslint*", "*vscode*", "*wallaby*", "authors", "changelog", "changes", "circle.yml", "component.json", "contributors", 
    "coverage", "doc", "docs", "example", "examples", "grunt*", "gulp*", "jenkins*", "jest.config.*", "jsconfig.json", 
    "karma.conf*", "licence", "licence.txt", "license", "license.txt", "makefile", "npm-debug.log", "powered-test", 
    "prettier.*", "test", "tests", "tsconfig.json"
)

$PROD_PATTERNS = @(
    "*.map", "*.mts", "*.ts"
)

if ($env:NODE_ENV -eq "production") {
    $PATTERNS += $PROD_PATTERNS
}

if ($env:NODE_ENV -ne "production") {
    Write-Host "$TARGET_DIR size before: $(Get-ChildItem $TARGET_DIR -Recurse | Measure-Object -Property Length -Sum | % { '{0:N2} MB' -f ($_.Sum / 1MB) })"
}

foreach ($pattern in $PATTERNS) {
    Get-ChildItem $TARGET_DIR -Recurse -Include $pattern | Remove-Item -Recurse -Force
}

if ($env:NODE_ENV -ne "production") {
    Write-Host "$TARGET_DIR size after: $(Get-ChildItem $TARGET_DIR -Recurse | Measure-Object -Property Length -Sum | % { '{0:N2} MB' -f ($_.Sum / 1MB) })"
}

@huqedato
Copy link
Author

huqedato commented Dec 7, 2023

Forked: https://github.com/huqedato/npmprunewin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants