The `AUDIT_EXIT_CODE` variable is set after the command completion, but `$?` may not reflect the correct exit code due to the assignment operation. Store the exit code immediately: `npm audit --json 2>&1; AUDIT_EXIT_CODE=$?; AUDIT_OUTPUT=$(npm audit --json 2>&1)` or use a different approach to capture both output and exit code reliably.
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
The AUDIT_EXIT_CODE variable is set after the command completion, but $? may not reflect the correct exit code due to the assignment operation. Store the exit code immediately: npm audit --json 2>&1; AUDIT_EXIT_CODE=$?; AUDIT_OUTPUT=$(npm audit --json 2>&1) or use a different approach to capture both output and exit code reliably.
# Run npm audit and capture output and exit code reliably
npm audit --json 2>&1 | tee audit_output.json > /dev/null
AUDIT_EXIT_CODE=$?
AUDIT_OUTPUT=$(cat audit_output.json)
rm -f audit_output.json
Originally posted by @Copilot in https://github.com/actions/runner/pull/4025#discussion_r2333458469
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the runner code that invokes npm audit and assigns AUDIT_EXIT_CODE, then read how its output is consumed. Reproduce the audit command with success and failure cases, and verify that the captured output and exit code both remain correct after the change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, shell
- Domain
- devops, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100