SDT/scripts/npm-clean.py
2026-03-01 20:52:56 -06:00

36 lines
978 B
Python

#!/usr/bin/env python3
import argparse
import shutil
from script_common import resolve_repo_root
def main() -> int:
parser = argparse.ArgumentParser(description="Cross-platform node_modules cleanup")
parser.add_argument("--repo-root", default=None)
parser.add_argument("--working-dir", default=".")
parser.add_argument("--also-cache", action="store_true")
args = parser.parse_args()
repo_root = resolve_repo_root(args.repo_root)
work_dir = (repo_root / args.working_dir).resolve()
node_modules = work_dir / "node_modules"
if node_modules.exists():
shutil.rmtree(node_modules)
print(f"Removed: {node_modules}")
else:
print(f"Not found: {node_modules}")
if args.also_cache:
npm_cache = repo_root / ".npm" / "cache"
if npm_cache.exists():
shutil.rmtree(npm_cache)
print(f"Removed: {npm_cache}")
return 0
if __name__ == "__main__":
raise SystemExit(main())