npmprune
npmprune copied to clipboard
Windows ?
Hi,
Great to have a Windows version... Powershell.
Thanks.
Contributions are welcome.
Exactly!
And you can use this code as a foundation (made by GTP-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) })"
}
Forked: https://github.com/huqedato/npmprunewin