bin scripts: Promisify db.init and db.close

pull/4656/head
Richard Hansen 2021-01-09 03:08:50 -05:00 committed by John McLear
parent 0a61767901
commit c622894fe0
1 changed files with 26 additions and 33 deletions

View File

@ -71,11 +71,7 @@ const unescape = (val) => {
if (!sqlFile) throw new Error('Use: node importSqlFile.js $SQLFILE');
log('initializing db');
db.init((err) => {
// there was an error while initializing the database, output it and stop
if (err) {
throw err;
} else {
await util.promisify(db.init.bind(db))();
log('done');
log('open output file...');
@ -104,9 +100,6 @@ const unescape = (val) => {
process.stdout.write('done. waiting for db to finish transaction. ' +
'depended on dbms this may take some time..\n');
db.close(() => {
await util.promisify(db.close.bind(db))();
log(`finished, imported ${keyNo} keys.`);
});
}
});
})();