Skip to content

Commit 718a4bd

Browse files
committed
NO-ISSUE a
1 parent 2feb4ae commit 718a4bd

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

.github/workflows/npm-audit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
- name: Create or update reminder issue
2929
if: steps.audit.outcome == 'failure'
30-
uses: actions/github-script@v7
30+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
3131
env:
3232
TZ: 'Asia/Tokyo'
3333
with:

scripts/npm-audit.sh

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
find . -name package-lock.json \
2-
-not -path "./node_modules/*" \
3-
-execdir sh -c '
4-
printf "\033[1;34m==> %s\033[0m\n" "$PWD"
5-
npm audit fix --force
6-
' \;
7-
8-
if [ -n "$(git status --porcelain)" ]; then
9-
echo "Changes detected after 'npm audit fix'"
10-
exit 1
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
errors=0
5+
6+
find . -name package-lock.json -not -path "./node_modules/*" -print0 |
7+
xargs -0 -n1 dirname | sort -u |
8+
while IFS= read -r dir; do
9+
printf '\n\n\n'
10+
printf '\033[1;34m==> %s\033[0m\n' "$dir"
11+
(cd "$dir" && npm audit) || errors=1
12+
done
13+
14+
if [ "$errors" -eq 0 ]; then
15+
echo "npm audit passed: no vulnerabilities detected"
1116
else
12-
echo "No changes detected after 'npm audit fix'"
17+
echo "npm audit reported vulnerabilities. Fix all vulnerabilities before committing."
1318
fi
19+
20+
exit "$errors"

0 commit comments

Comments
 (0)