Skip to content

Commit

Permalink
fix: set the test env differently
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed May 6, 2024
1 parent bd31b44 commit e5c7e14
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"editor.formatOnPaste": false,
"editor.formatOnType": false,
"editor.formatOnSave": true,
"workbench.colorTheme": "FireFly Pro Bright"
"workbench.colorTheme": "Sublime Material Theme - Light"
}
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ const npmInstallAction = async () => {
// From: https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/src/saveImpl.ts#L96
if (process.env.NODE_ENV !== 'test') {
process.exit(0)
} else {
core.debug('skip process.exit(0) in test mode')
}
} catch (err) {
console.error(err)
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ const npmInstallAction = async () => {
// From: https://github.com/actions/cache/blob/a2ed59d39b352305bdd2f628719a53b2cc4f9613/src/saveImpl.ts#L96
if (process.env.NODE_ENV !== 'test') {
process.exit(0)
} else {
core.debug('skip process.exit(0) in test mode')
}
} catch (err) {
console.error(err)
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": "NODE_ENV=test npm run unit",
"test": "npm run unit",
"unit": "mocha test/helper 'test/*spec.js'",
"pretest": "npm run build",
"build": "ncc build -o dist index.js",
Expand Down
3 changes: 3 additions & 0 deletions test/helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// https://github.com/bahmutov/npm-install/pull/228
process.env.NODE_ENV = 'test'

// following guide
// https://glebbahmutov.com/blog/mocha-and-sinon/
const chai = require('chai')
Expand Down

0 comments on commit e5c7e14

Please sign in to comment.