Skip to content

Commit

Permalink
replace skipped promisify
Browse files Browse the repository at this point in the history
  • Loading branch information
maxeljkin committed Oct 14, 2019
1 parent 06575af commit 59bf421
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
17 changes: 11 additions & 6 deletions 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,
Expand All @@ -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) {
Expand Down Expand Up @@ -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}`));
Expand Down Expand Up @@ -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');
});
Expand Down
13 changes: 6 additions & 7 deletions test/knexfile.js
Expand Up @@ -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 = (
Expand All @@ -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);
});
},
});

Expand Down

0 comments on commit 59bf421

Please sign in to comment.