Skip to content

Commit 486cb78

Browse files
committed
fix(exitCode): wrong exit code on db methods
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 <[email protected]>
1 parent b1a3869 commit 486cb78

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/commands/db.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ function executeDB (internals, config, callback) {
2525
function (err) {
2626
if (err) {
2727
if (err.error) err = err.error;
28-
log.info('Error: Failed to create database!', err);
28+
log.error('Error: Failed to create database!', err);
2929
} else {
3030
log.info('Created database "' + internals.argv.dbname + '"');
3131
}
3232

3333
db.close();
34-
if (typeof callback === 'function') callback();
34+
if (typeof callback === 'function') callback(err);
35+
else process.exit(1);
3536
}
3637
);
3738
} else if (internals.mode === 'drop') {
@@ -43,13 +44,14 @@ function executeDB (internals, config, callback) {
4344
function (err) {
4445
if (err) {
4546
if (err.error) err = err.error;
46-
log.info('Error: Failed to drop database!', err);
47+
log.error('Error: Failed to drop database!', err);
4748
} else {
4849
log.info('Deleted database "' + internals.argv.dbname + '"');
4950
}
5051

5152
db.close();
52-
if (typeof callback === 'function') callback();
53+
if (typeof callback === 'function') callback(err);
54+
process.exit(1);
5355
}
5456
);
5557
}

0 commit comments

Comments
 (0)