Skip to content

Commit

Permalink
fix: Do not exit in test environment
Browse files Browse the repository at this point in the history
  • Loading branch information
chloe463 committed May 3, 2024
1 parent c763c78 commit 9c319b8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,9 @@ const npmInstallAction = async () => {
// that all promises that we care about have successfully
// resolved, so simply exit with success.
// From: https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/src/saveImpl.ts#L96
process.exit(0)
if (process.env.NODE_ENV !== 'test') {
process.exit(0)
}
} catch (err) {
console.error(err)
core.setFailed(err.message)
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ const npmInstallAction = async () => {
// that all promises that we care about have successfully
// resolved, so simply exit with success.
// From: https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/src/saveImpl.ts#L96
process.exit(0)
if (process.env.NODE_ENV !== 'test') {
process.exit(0)
}
} catch (err) {
console.error(err)
core.setFailed(err.message)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"format": "prettier --write './**/*'",
"format:check": "prettier --check './**/*'",
"test": "npm run unit",
"test": "NODE_ENV=test npm run unit",
"unit": "mocha test/helper 'test/*spec.js'",
"pretest": "npm run build",
"build": "ncc build -o dist index.js",
Expand Down

0 comments on commit 9c319b8

Please sign in to comment.