Skip to content

Commit

Permalink
fix(exitCode): wrong exit code on db methods
Browse files Browse the repository at this point in the history
DB Calls always returned an exit code of 0, which leads
to an unexpected behavior on the user side.

Fixes #534

Signed-off-by: Tobias Gurtzick <magic@wizardtales.com>
  • Loading branch information
wzrdtales committed Feb 3, 2018
1 parent b1a3869 commit 486cb78
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/commands/db.js
Expand Up @@ -25,13 +25,14 @@ function executeDB (internals, config, callback) {
function (err) {
if (err) {
if (err.error) err = err.error;
log.info('Error: Failed to create database!', err);
log.error('Error: Failed to create database!', err);
} else {
log.info('Created database "' + internals.argv.dbname + '"');
}

db.close();
if (typeof callback === 'function') callback();
if (typeof callback === 'function') callback(err);
else process.exit(1);
}
);
} else if (internals.mode === 'drop') {
Expand All @@ -43,13 +44,14 @@ function executeDB (internals, config, callback) {
function (err) {
if (err) {
if (err.error) err = err.error;
log.info('Error: Failed to drop database!', err);
log.error('Error: Failed to drop database!', err);
} else {
log.info('Deleted database "' + internals.argv.dbname + '"');
}

db.close();
if (typeof callback === 'function') callback();
if (typeof callback === 'function') callback(err);
process.exit(1);
}
);
}
Expand Down

0 comments on commit 486cb78

Please sign in to comment.