Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
feat: handle uncaught exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Jul 7, 2020
1 parent 088ebc9 commit fa64e02
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ jobs:
run: npm test
- name: Set up stack for End-to-End tests
run: |
npx cdk -a 'node dist/cdk/cloudformation-sourcecode.js' deploy
npx cdk -a 'node --unhandled-rejections=strict dist/cdk/cloudformation-sourcecode.js' deploy
npx cdk bootstrap
npx cdk -a 'node dist/cdk/cloudformation-test.js' deploy --require-approval never
npx cdk -a 'node --unhandled-rejections=strict dist/cdk/cloudformation-test.js' deploy --require-approval never
node cli historical-data --setup -d
node cli create-ca
- name: End-to-End Tests
Expand All @@ -86,12 +86,12 @@ jobs:
node cli purge-cas -i `cat certificates/rootCA.id`
# Purge Buckets does not remove the source-code bucket (because it will be populate again by the CDK command)
node cli purge-buckets
npx cdk -a 'node dist/cdk/cloudformation-test.js' destroy -f '*'
npx cdk -a 'node --unhandled-rejections=strict dist/cdk/cloudformation-test.js' destroy -f '*'
# Delete sourcecode bucket
SOURCE_CODE_BUCKET=`aws cloudformation describe-stacks --stack-name $STACK_ID-sourcecode | jq -r '.Stacks[0].Outputs[] | select(.OutputKey == "bucketName") | .OutputValue'`
aws s3 rb s3://$SOURCE_CODE_BUCKET --force
# Delete the sourceode stack
npx cdk -a 'node dist/cdk/cloudformation-sourcecode.js' destroy -f '*'
npx cdk -a 'node --unhandled-rejections=strict dist/cdk/cloudformation-sourcecode.js' destroy -f '*'
release:
needs: tests
Expand Down
2 changes: 1 addition & 1 deletion cdk.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"app": "node dist/cdk/cloudformation.js"
"app": "node --unhandled-rejections=strict dist/cdk/cloudformation.js"
}
9 changes: 8 additions & 1 deletion cli/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/usr/bin/env node

process.on('uncaughtException', (err, origin) => {
process.exitCode = 1
console.error(`An unhandled exception occured!`)
console.error(`Exception origin: ${origin}`)
console.error(err)
})

// eslint-disable-next-line
require('../dist/cli/bifravst')
require('../dist/cli/bifravst')
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "AWS-based implementation of Bifravst",
"scripts": {
"test": "jest",
"test:e2e": "node dist/feature-runner/run-features.js ./features --print-results --progress",
"test:e2e": "node --unhandled-rejections=strict dist/feature-runner/run-features.js ./features --print-results --progress",
"postinstall": "check-node-version --package"
},
"repository": {
Expand Down

0 comments on commit fa64e02

Please sign in to comment.