File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,21 +7,10 @@ input=$(cat)
77# Extract command field from JSON
88command=$( echo " $input " | grep -o ' "command":"[^"]*' | cut -d' "' -f4 | head -1)
99
10- # Check if command starts with npm or npx
11- if [[ " $command " =~ ^npm[[:space:]] ]] || [[ " $command " =~ ^npx[[:space:]] ]]; then
12- # Extract the npm command for suggestion
13- npm_cmd=$( echo " $command " | cut -d' ' -f1)
14- rest=$( echo " $command " | cut -d' ' -f2-)
15-
16- # Suggest pnpm equivalent
17- if [ " $npm_cmd " = " npm" ]; then
18- suggested=" pnpm $rest "
19- elif [ " $npm_cmd " = " npx" ]; then
20- suggested=" pnpx $rest "
21- fi
22-
23- echo " ❌ npm is not allowed in this workspace. Use pnpm instead." >&2
24- echo " 💡 Suggested: $suggested " >&2
10+ # Check if command contains npm or npx as a standalone word (catches compound commands like "cd /x && npx foo")
11+ if [[ " $command " =~ (^| [;& | [:space:]])npm[[:space:]] ]] || [[ " $command " =~ (^| [;& | [:space:]])npx[[:space:]] ]]; then
12+ echo " ❌ npm/npx is not allowed in this workspace. Use pnpm/pnpx instead." >&2
13+ echo " 💡 Command: $command " >&2
2514 exit 2
2615fi
2716
You can’t perform that action at this time.
0 commit comments