-
-
Notifications
You must be signed in to change notification settings - Fork 360
Expand file tree
/
Copy pathon-complete.js
More file actions
29 lines (25 loc) · 795 Bytes
/
on-complete.js
File metadata and controls
29 lines (25 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var assert = require('assert');
var log = require('db-migrate-shared').log;
const Promise = require('bluebird');
module.exports = function (migrator, internals, originalErr, results) {
return Promise.fromCallback(callback => {
migrator.driver.close(function (err) {
if ((err || originalErr) && typeof callback === 'function') {
callback(originalErr || err);
return;
} else {
if (originalErr instanceof Error) throw originalErr;
assert.ifError(originalErr);
assert.ifError(err);
log.info('Done');
}
if (internals.argv['force-exit']) {
log.verbose('Forcing exit');
return process.exit(0);
}
if (typeof callback === 'function') {
callback(null, results);
}
});
});
};