Skip to content

Commit

Permalink
attempt to catch exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
dangowans committed Nov 24, 2023
1 parent 38907a1 commit cd18c4e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ jobs:
npm install -g eslint
- name: Run Test (Should Fail)
run: |
npm test
exitcode="$?"
echo "exitcode=$exitcode"
exit "$exitcode"
run: npm test

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"main": "eslint-config-cityssm.js",
"scripts": {
"test": "eslint test/**"
"test": "node ./test/runEslint.mjs"
},
"keywords": [
"eslint-config"
Expand Down Expand Up @@ -33,5 +33,7 @@
},
"devDependencies": {
"@types/node": "^20.10.0"
"@types/node": "^20.10.0",
"execa": "^8.0.1"
}
}
5 changes: 5 additions & 0 deletions test/runEslint.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { execa } from 'execa';
// eslint-disable-next-line unicorn/prefer-top-level-await
execa('eslint --exit-on-fatal-error test/test.ts', { stdio: 'inherit' }).catch((error) => {
process.exitCode = error.exitCode === 1 ? 0 : 1;
});
8 changes: 8 additions & 0 deletions test/runEslint.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { execa } from 'execa'

// eslint-disable-next-line unicorn/prefer-top-level-await
execa('eslint --exit-on-fatal-error test/test.ts', { stdio: 'inherit' }).catch(
(error) => {
process.exitCode = error.exitCode === 1 ? 0 : 1
}
)

0 comments on commit cd18c4e

Please sign in to comment.