From 59bf421cb191f44d2510a2db8307eac50c45cfc2 Mon Sep 17 00:00:00 2001 From: maxeljkin Date: Wed, 9 Oct 2019 01:47:35 +0300 Subject: [PATCH] replace skipped promisify --- bin/cli.js | 17 +++++++++++------ test/knexfile.js | 13 ++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bin/cli.js b/bin/cli.js index 5c7597dce2..453b432407 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -1,14 +1,14 @@ #!/usr/bin/env node /* eslint no-console:0, no-var:0 */ const Liftoff = require('liftoff'); -const Bluebird = require('bluebird'); const interpret = require('interpret'); const path = require('path'); const tildify = require('tildify'); const commander = require('commander'); const color = require('colorette'); const argv = require('getopts')(process.argv.slice(2)); -const fs = Bluebird.promisifyAll(require('fs')); +const fs = require('fs'); +const { promisify } = require('util'); const cliPkg = require('../package'); const { mkConfigObj, @@ -24,6 +24,11 @@ const { const { listMigrations } = require('./utils/migrationsLister'); +const fsPromised = { + readFile: promisify(fs.readFile), + writeFile: promisify(fs.writeFile), +}; + function initKnex(env, opts) { checkLocalModule(env); if (process.cwd() !== env.cwd) { @@ -124,15 +129,15 @@ function invoke(env) { } checkLocalModule(env); const stubPath = `./knexfile.${type}`; - pending = fs - .readFileAsync( + pending = fsPromised + .readFile( path.dirname(env.modulePath) + '/lib/migrate/stub/knexfile-' + type + '.stub' ) .then((code) => { - return fs.writeFileAsync(stubPath, code); + return fsPromised.writeFile(stubPath, code); }) .then(() => { success(color.green(`Created ${stubPath}`)); @@ -338,7 +343,7 @@ function invoke(env) { commander.parse(process.argv); - Bluebird.resolve(pending).then(() => { + Promise.resolve(pending).then(() => { commander.outputHelp(); exit('Unknown command-line options, exiting'); }); diff --git a/test/knexfile.js b/test/knexfile.js index 0f3c2cc069..a7ba7eecf3 100644 --- a/test/knexfile.js +++ b/test/knexfile.js @@ -2,10 +2,10 @@ /* eslint no-var: 0 */ const assert = require('assert'); +const { promisify } = require('util'); const testConfig = (process.env.KNEX_TEST && require(process.env.KNEX_TEST)) || {}; const _ = require('lodash'); -const Bluebird = require('bluebird'); // excluding redshift, oracle, and mssql dialects from default integrations test const testIntegrationDialects = ( @@ -31,12 +31,11 @@ const poolSqlite = { const mysqlPool = _.extend({}, pool, { afterCreate: function(connection, callback) { - Bluebird.promisify(connection.query, { context: connection })( - "SET sql_mode='TRADITIONAL';", - [] - ).then(function() { - callback(null, connection); - }); + promisify(connection.query) + .call(connection, "SET sql_mode='TRADITIONAL';", []) + .then(function() { + callback(null, connection); + }); }, });