Skip to content

Commit 0f4b69e

Browse files
committed
Exit with a non-zero exit code on error
Since this script is used in CI environments to deploy lambdas, it should always exit with a non-zero exit code if an error is returned by the AWS SDK so that CI jobs can report as failed.
1 parent 9651747 commit 0f4b69e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

dpl.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ if (pkg.files_to_deploy.indexOf('.env') > -1) {
99
dpl.install_node_modules(); // install only production node_modules
1010
dpl.zip(); // zip the /dist directory
1111
dpl.upload(function (err, data) { // upload the .zip file to AWS:
12+
var exitcode = 0;
1213
if (err) {
1314
console.log('- - - - - - - - - - - - - - - - - - - - - - - DEPLOY ERROR');
1415
console.log(err);
1516
console.log('- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -');
17+
exitcode = 1;
18+
} else {
19+
console.log('- - - - - - - - > Lambda Function Deployed:');
20+
console.log(data);
21+
console.log('- - - - - - - - > took', (Date.now() - start) / 1000, 'seconds');
1622
}
17-
console.log('- - - - - - - - > Lambda Function Deployed:');
18-
console.log(data);
19-
console.log('- - - - - - - - > took', (Date.now() - start) / 1000, 'seconds');
2023
dpl.utils.clean_up(); // delete /dist and .zip file for next time
24+
process.exit(exitcode);
2125
});

0 commit comments

Comments
 (0)