diff --git a/package.json b/package.json index e993fce731..8bd1c72b60 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,8 @@ "prerun": "bash configure.sh", "typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js", "uninstall": "bash uninstall.sh", + "clean-modules": "bash remove-node-modules.sh", + "install-modules": "bash install-node-modules.sh", "lint": "export NODE_OPTIONS='--max-old-space-size=32768' && npx eslint . --cache", "fix-lint": "export NODE_OPTIONS='--max-old-space-size=32768' && npx eslint . --fix --cache --debug", "fix": "npm run fix-lint", diff --git a/remove-node-modules.sh b/remove-node-modules.sh index be8ea79653..567450623e 100644 --- a/remove-node-modules.sh +++ b/remove-node-modules.sh @@ -1,7 +1,21 @@ +#!/bin/bash + +echo "Removing node_modules directories..." for d in */ ; do - cd $d || echo "Cannot cd into $d" - rm -rf node_modules || echo "node_modules directory not found $d" - cd .. || echo "Cannot cd out" -done \ No newline at end of file + if [ -d "$d" ]; then + cd "$d" || { echo "Cannot cd into $d"; continue; } + + if [ -d "node_modules" ]; then + echo "Removing node_modules in $d" + rm -rf node_modules || echo "Failed to remove node_modules in $d" + else + echo "No node_modules found in $d" + fi + + cd .. || echo "Cannot cd out of $d" + fi +done + +echo "Finished removing node_modules directories." \ No newline at end of file