Skip to content

Commit

Permalink
Merge pull request #1 from souzaramon/refactor/use-find
Browse files Browse the repository at this point in the history
refactor: use find + exec, also allow dir via argv1
  • Loading branch information
devMoisa authored Mar 10, 2023
2 parents 70b91c3 + e7afda7 commit b6ede0a
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions clearNodeModules.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
#!/bin/bash
#! /usr/bin/env sh
set -e

function delete_node_modules {
for file in "$1"/*; do
if [[ -d "$file" ]]; then
if [[ "$file" == *"/node_modules" ]]; then
echo "Deletando $file"
rm -rf "$file"
else
delete_node_modules "$file"
fi
fi
done
}

delete_node_modules "$(pwd)"
find "${1-"$(pwd)"}" -name 'node_modules' -type d -prune -exec rm -rf '{}' +

0 comments on commit b6ede0a

Please sign in to comment.