mirror of
https://github.com/knex/knex.git
synced 2025-06-26 22:00:25 +00:00
Additional lint checks before publishing (#5459)
This commit is contained in:
parent
5caf526c27
commit
9a6c5ba62f
@ -10,11 +10,12 @@ module.exports = {
|
|||||||
'plugin:import/warnings',
|
'plugin:import/warnings',
|
||||||
'prettier',
|
'prettier',
|
||||||
],
|
],
|
||||||
plugins: ['import', 'mocha-no-only'],
|
plugins: ['prettier', 'import', 'mocha-no-only'],
|
||||||
rules: {
|
rules: {
|
||||||
'mocha-no-only/mocha-no-only': ['error'],
|
'mocha-no-only/mocha-no-only': ['error'],
|
||||||
'no-unused-vars': [warning, { vars: 'all', args: 'none' }],
|
'no-unused-vars': [warning, { vars: 'all', args: 'none' }],
|
||||||
'no-console': 'off',
|
'no-console': 'off',
|
||||||
|
'no-empty': 'off',
|
||||||
'no-var': 2,
|
'no-var': 2,
|
||||||
'no-debugger': warning,
|
'no-debugger': warning,
|
||||||
'prefer-const': warning,
|
'prefer-const': warning,
|
||||||
|
11
bin/cli.js
11
bin/cli.js
@ -218,7 +218,7 @@ function invoke() {
|
|||||||
.action(async (name) => {
|
.action(async (name) => {
|
||||||
try {
|
try {
|
||||||
const opts = commander.opts();
|
const opts = commander.opts();
|
||||||
const instance = await initKnex(env, opts, true); // Skip config check, we don't really care about client when creating migrations
|
const instance = await initKnex(env, opts, true); // Skip config check, we don't really care about client when creating migrations
|
||||||
const ext = getMigrationExtension(env, opts);
|
const ext = getMigrationExtension(env, opts);
|
||||||
const configOverrides = { extension: ext };
|
const configOverrides = { extension: ext };
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ function invoke() {
|
|||||||
success(color.green(`Created Migration: ${name}`));
|
success(color.green(`Created Migration: ${name}`));
|
||||||
})
|
})
|
||||||
.catch(exit);
|
.catch(exit);
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -397,7 +397,8 @@ function invoke() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (opts.timestampFilenamePrefix) {
|
if (opts.timestampFilenamePrefix) {
|
||||||
configOverrides.timestampFilenamePrefix = opts.timestampFilenamePrefix;
|
configOverrides.timestampFilenamePrefix =
|
||||||
|
opts.timestampFilenamePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance.seed
|
instance.seed
|
||||||
@ -406,9 +407,9 @@ function invoke() {
|
|||||||
success(color.green(`Created seed file: ${name}`));
|
success(color.green(`Created seed file: ${name}`));
|
||||||
})
|
})
|
||||||
.catch(exit);
|
.catch(exit);
|
||||||
} catch(err) {
|
} catch (err) {
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
commander
|
commander
|
||||||
|
@ -120,7 +120,9 @@ class SchemaCompiler_PG extends SchemaCompiler {
|
|||||||
|
|
||||||
refreshMaterializedView(viewName, concurrently = false) {
|
refreshMaterializedView(viewName, concurrently = false) {
|
||||||
this.pushQuery({
|
this.pushQuery({
|
||||||
sql: `refresh materialized view${concurrently ? " concurrently" : ""} ${this.formatter.wrap(viewName)}`,
|
sql: `refresh materialized view${
|
||||||
|
concurrently ? ' concurrently' : ''
|
||||||
|
} ${this.formatter.wrap(viewName)}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ knex.ColumnBuilder = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
knex.TableBuilder = {
|
knex.TableBuilder = {
|
||||||
extend: function (methodName, fn) {
|
extend: function (methodName, fn) {
|
||||||
TableBuilder.extend(methodName, fn);
|
TableBuilder.extend(methodName, fn);
|
||||||
},
|
},
|
||||||
|
@ -41,7 +41,9 @@ class MigrationGenerator {
|
|||||||
|
|
||||||
_getNewMigrationName(name) {
|
_getNewMigrationName(name) {
|
||||||
if (name[0] === '-') name = name.slice(1);
|
if (name[0] === '-') name = name.slice(1);
|
||||||
return yyyymmddhhmmss() + '_' + name + '.' + this.config.extension.split('-')[0];
|
return (
|
||||||
|
yyyymmddhhmmss() + '_' + name + '.' + this.config.extension.split('-')[0]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_getNewMigrationPath(name) {
|
_getNewMigrationPath(name) {
|
||||||
|
@ -97,9 +97,10 @@ class SchemaBuilder extends EventEmitter {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
SchemaBuilder.extend = (methodName, fn) => {
|
SchemaBuilder.extend = (methodName, fn) => {
|
||||||
if (Object.prototype.hasOwnProperty.call(SchemaBuilder.prototype, methodName)) {
|
if (
|
||||||
|
Object.prototype.hasOwnProperty.call(SchemaBuilder.prototype, methodName)
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Can't extend SchemaBuilder with existing method ('${methodName}').`
|
`Can't extend SchemaBuilder with existing method ('${methodName}').`
|
||||||
);
|
);
|
||||||
|
@ -88,9 +88,10 @@ ColumnBuilder.prototype.notNull = ColumnBuilder.prototype.notNullable =
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ColumnBuilder.extend = (methodName, fn) => {
|
ColumnBuilder.extend = (methodName, fn) => {
|
||||||
if (Object.prototype.hasOwnProperty.call(ColumnBuilder.prototype, methodName)) {
|
if (
|
||||||
|
Object.prototype.hasOwnProperty.call(ColumnBuilder.prototype, methodName)
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Can't extend ColumnBuilder with existing method ('${methodName}').`
|
`Can't extend ColumnBuilder with existing method ('${methodName}').`
|
||||||
);
|
);
|
||||||
|
@ -361,9 +361,10 @@ AlterMethods.dropColumn = AlterMethods.dropColumns = function () {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TableBuilder.extend = (methodName, fn) => {
|
TableBuilder.extend = (methodName, fn) => {
|
||||||
if (Object.prototype.hasOwnProperty.call(TableBuilder.prototype, methodName)) {
|
if (
|
||||||
|
Object.prototype.hasOwnProperty.call(TableBuilder.prototype, methodName)
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Can't extend TableBuilder with existing method ('${methodName}').`
|
`Can't extend TableBuilder with existing method ('${methodName}').`
|
||||||
);
|
);
|
||||||
|
@ -79,7 +79,6 @@ const AlterMethods = {
|
|||||||
|
|
||||||
helpers.addQueryContext(ViewBuilder);
|
helpers.addQueryContext(ViewBuilder);
|
||||||
|
|
||||||
|
|
||||||
ViewBuilder.extend = (methodName, fn) => {
|
ViewBuilder.extend = (methodName, fn) => {
|
||||||
if (Object.prototype.hasOwnProperty.call(ViewBuilder.prototype, methodName)) {
|
if (Object.prototype.hasOwnProperty.call(ViewBuilder.prototype, methodName)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
12
package.json
12
package.json
@ -13,10 +13,11 @@
|
|||||||
"build:ts": "tsc",
|
"build:ts": "tsc",
|
||||||
"build:gitignore": "node scripts/update_gitignore_for_tsc_output.js run",
|
"build:gitignore": "node scripts/update_gitignore_for_tsc_output.js run",
|
||||||
"format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"",
|
"format": "prettier --write \"{lib,bin,scripts,test}/**/*.js\"",
|
||||||
|
"format:check-difference": "prettier --list-different \"{lib,bin,scripts,test}/**/*.js\"",
|
||||||
"debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js",
|
"debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js",
|
||||||
"debug:tape": "node --inspect-brk test/tape/index.js",
|
"debug:tape": "node --inspect-brk test/tape/index.js",
|
||||||
"coveralls": "nyc report --reporter=lcov",
|
"coveralls": "nyc report --reporter=lcov",
|
||||||
"lint": "eslint \"lib/**/*.js\" \"test/**/*.js\"",
|
"lint": "eslint \"lib/**/*.js\" \"test/**/*.js\" \"bin/**/*.js\"",
|
||||||
"lint:types": "tsd && dtslint types",
|
"lint:types": "tsd && dtslint types",
|
||||||
"lint:everything": "npm run lint:types && npm run lint",
|
"lint:everything": "npm run lint:types && npm run lint",
|
||||||
"test:unit": "npm run test:unit-only && npm run test:cli",
|
"test:unit": "npm run test:unit-only && npm run test:cli",
|
||||||
@ -57,7 +58,7 @@
|
|||||||
"stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '",
|
"stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '",
|
||||||
"stress:destroy": "docker-compose -f scripts/stress-test/docker-compose.yml stop",
|
"stress:destroy": "docker-compose -f scripts/stress-test/docker-compose.yml stop",
|
||||||
"prepare": "husky install && npm run clean && npm run build",
|
"prepare": "husky install && npm run clean && npm run build",
|
||||||
"prepublishOnly": "npm run clean && npm run build"
|
"prepublishOnly": "npm run format:check-difference && npm run lint && npm run clean && npm run build"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"colorette": "2.0.19",
|
"colorette": "2.0.19",
|
||||||
@ -114,10 +115,11 @@
|
|||||||
"coveralls": "^3.1.1",
|
"coveralls": "^3.1.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"dtslint": "4.2.1",
|
"dtslint": "4.2.1",
|
||||||
"eslint": "^8.13.0",
|
"eslint": "^8.32.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-mocha-no-only": "^1.1.1",
|
"eslint-plugin-mocha-no-only": "^1.1.1",
|
||||||
|
"eslint-plugin-prettier": "^4.2.1",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
"jake": "^10.8.5",
|
"jake": "^10.8.5",
|
||||||
"JSONStream": "^1.3.5",
|
"JSONStream": "^1.3.5",
|
||||||
@ -130,7 +132,7 @@
|
|||||||
"oracledb": "^5.4.0",
|
"oracledb": "^5.4.0",
|
||||||
"pg": "^8.8.0",
|
"pg": "^8.8.0",
|
||||||
"pg-query-stream": "^4.2.4",
|
"pg-query-stream": "^4.2.4",
|
||||||
"prettier": "2.6.2",
|
"prettier": "2.8.3",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"sinon": "^15.0.1",
|
"sinon": "^15.0.1",
|
||||||
"sinon-chai": "^3.7.0",
|
"sinon-chai": "^3.7.0",
|
||||||
|
@ -1,29 +1,31 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs');
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
const { execSync } = require("child_process");
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
const repoDir = path.dirname(__dirname)
|
const repoDir = path.dirname(__dirname);
|
||||||
const gitDir = path.join(repoDir, '.git')
|
const gitDir = path.join(repoDir, '.git');
|
||||||
const gitDirExists = doesDirectoryExist(gitDir)
|
const gitDirExists = doesDirectoryExist(gitDir);
|
||||||
if (!gitDirExists) {
|
if (!gitDirExists) {
|
||||||
console.log("No .git directory detected so can not clean 'lib/'. Exiting.")
|
console.log("No .git directory detected so can not clean 'lib/'. Exiting.");
|
||||||
process.exit(0)
|
process.exit(0);
|
||||||
}
|
}
|
||||||
console.log("Cleaning 'lib/' of outputted files from Typescript compilation ...")
|
console.log(
|
||||||
const cmd = 'git clean -f -X lib/'
|
"Cleaning 'lib/' of outputted files from Typescript compilation ..."
|
||||||
const output = execSync(cmd, { cwd: repoDir })
|
);
|
||||||
console.log(output.toString('utf8'))
|
const cmd = 'git clean -f -X lib/';
|
||||||
console.log('Done')
|
const output = execSync(cmd, { cwd: repoDir });
|
||||||
|
console.log(output.toString('utf8'));
|
||||||
|
console.log('Done');
|
||||||
}
|
}
|
||||||
|
|
||||||
function doesDirectoryExist(p) {
|
function doesDirectoryExist(p) {
|
||||||
if (fs.existsSync(p)) {
|
if (fs.existsSync(p)) {
|
||||||
return fs.lstatSync(p).isDirectory()
|
return fs.lstatSync(p).isDirectory();
|
||||||
}
|
}
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main();
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path');
|
||||||
const fs = require('fs')
|
const fs = require('fs');
|
||||||
|
|
||||||
// Directory constants
|
// Directory constants
|
||||||
const scriptDirectory = __dirname
|
const scriptDirectory = __dirname;
|
||||||
const repoDirectory = path.join(scriptDirectory, '..')
|
const repoDirectory = path.join(scriptDirectory, '..');
|
||||||
const libDirectory = path.join(repoDirectory, 'lib')
|
const libDirectory = path.join(repoDirectory, 'lib');
|
||||||
|
|
||||||
const helpText = `
|
const helpText = `
|
||||||
Helper script to update lib/.gitignore for all .js files from .ts files.
|
Helper script to update lib/.gitignore for all .js files from .ts files.
|
||||||
@ -19,7 +19,7 @@ Helper script to update lib/.gitignore for all .js files from .ts files.
|
|||||||
|
|
||||||
NOTES FOR USAGE:
|
NOTES FOR USAGE:
|
||||||
1. This script is tested to work on Ubuntu 18.04 LTS.
|
1. This script is tested to work on Ubuntu 18.04 LTS.
|
||||||
`
|
`;
|
||||||
|
|
||||||
const gitignoreHeader = `# DO NOT EDIT, GENERATED BY: scripts/update_gitignore_for_tsc_output.js
|
const gitignoreHeader = `# DO NOT EDIT, GENERATED BY: scripts/update_gitignore_for_tsc_output.js
|
||||||
|
|
||||||
@ -30,57 +30,61 @@ const gitignoreHeader = `# DO NOT EDIT, GENERATED BY: scripts/update_gitignore_f
|
|||||||
**/*.js.map
|
**/*.js.map
|
||||||
|
|
||||||
# Do not include .js files from .ts files
|
# Do not include .js files from .ts files
|
||||||
`
|
`;
|
||||||
|
|
||||||
function main(cliCommand) {
|
function main(cliCommand) {
|
||||||
if (cliCommand === 'run') {
|
if (cliCommand === 'run') {
|
||||||
console.log('Generating lib/.gitignore ...')
|
console.log('Generating lib/.gitignore ...');
|
||||||
|
|
||||||
// Find all .ts files in lib/
|
// Find all .ts files in lib/
|
||||||
const directoriesToProcess = [libDirectory]
|
const directoriesToProcess = [libDirectory];
|
||||||
const tsFiles = []
|
const tsFiles = [];
|
||||||
while (directoriesToProcess.length > 0) {
|
while (directoriesToProcess.length > 0) {
|
||||||
const directory = directoriesToProcess.pop()
|
const directory = directoriesToProcess.pop();
|
||||||
if (!fs.existsSync(directory)) {
|
if (!fs.existsSync(directory)) {
|
||||||
throw new Error("Directory doesn't exist:", directory)
|
throw new Error("Directory doesn't exist:", directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
const files = fs.readdirSync(directory)
|
const files = fs.readdirSync(directory);
|
||||||
files.forEach((file) => {
|
files.forEach((file) => {
|
||||||
const filename = path.join(directory, file)
|
const filename = path.join(directory, file);
|
||||||
const stat = fs.lstatSync(filename)
|
const stat = fs.lstatSync(filename);
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
directoriesToProcess.push(filename)
|
directoriesToProcess.push(filename);
|
||||||
} else if (filename.endsWith('.ts') && !filename.endsWith('.d.ts')) {
|
} else if (filename.endsWith('.ts') && !filename.endsWith('.d.ts')) {
|
||||||
tsFiles.push(filename)
|
tsFiles.push(filename);
|
||||||
console.log('Found .ts file:', filename)
|
console.log('Found .ts file:', filename);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get paths of .js files to ignore
|
// Get paths of .js files to ignore
|
||||||
const jsFilesToIgnore = tsFiles.map((filepath) => {
|
const jsFilesToIgnore = tsFiles.map((filepath) => {
|
||||||
// Cuts off `${libDirectory}/`
|
// Cuts off `${libDirectory}/`
|
||||||
const relativeTsPath = filepath.slice(libDirectory.length + 1)
|
const relativeTsPath = filepath.slice(libDirectory.length + 1);
|
||||||
// Swaps .ts for .js file ending
|
// Swaps .ts for .js file ending
|
||||||
const relativeJsPath = relativeTsPath.slice(0, relativeTsPath.length - 3) + '.js'
|
const relativeJsPath =
|
||||||
|
relativeTsPath.slice(0, relativeTsPath.length - 3) + '.js';
|
||||||
// Always use POSIX-style path separators - .gitignore requires it
|
// Always use POSIX-style path separators - .gitignore requires it
|
||||||
return relativeJsPath.split(path.sep).join(path.posix.sep);
|
return relativeJsPath.split(path.sep).join(path.posix.sep);
|
||||||
})
|
});
|
||||||
const jsFilesToIgnoreString = jsFilesToIgnore.join('\n')
|
const jsFilesToIgnoreString = jsFilesToIgnore.join('\n');
|
||||||
const libGitignorePath = path.join(libDirectory, '.gitignore')
|
const libGitignorePath = path.join(libDirectory, '.gitignore');
|
||||||
fs.writeFileSync(libGitignorePath, gitignoreHeader + jsFilesToIgnoreString + '\n')
|
fs.writeFileSync(
|
||||||
console.log('DONE')
|
libGitignorePath,
|
||||||
|
gitignoreHeader + jsFilesToIgnoreString + '\n'
|
||||||
|
);
|
||||||
|
console.log('DONE');
|
||||||
} else if (['help', '--help', '-h', undefined].includes(cliCommand)) {
|
} else if (['help', '--help', '-h', undefined].includes(cliCommand)) {
|
||||||
console.log(helpText)
|
console.log(helpText);
|
||||||
} else {
|
} else {
|
||||||
console.log(`Unsupported command: ${cliCommand}`)
|
console.log(`Unsupported command: ${cliCommand}`);
|
||||||
console.log("Try running with 'help' to see supported commands.")
|
console.log("Try running with 'help' to see supported commands.");
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main script logic
|
// Main script logic
|
||||||
const cliCommand = process.argv[2]
|
const cliCommand = process.argv[2];
|
||||||
// Start the bash app's main function
|
// Start the bash app's main function
|
||||||
main(cliCommand)
|
main(cliCommand);
|
||||||
|
@ -66,9 +66,9 @@ describe('Oracle', () => {
|
|||||||
const sql = compiler.insert();
|
const sql = compiler.insert();
|
||||||
expect(sql.sql).to.eql(
|
expect(sql.sql).to.eql(
|
||||||
'begin execute immediate \'insert into "fakeTable" ("value1", "value2", "value3", "value4") values ' +
|
'begin execute immediate \'insert into "fakeTable" ("value1", "value2", "value3", "value4") values ' +
|
||||||
'(:1, :2, :3, :4)\' using ?, ?, ?, ?; ' +
|
"(:1, :2, :3, :4)' using ?, ?, ?, ?; " +
|
||||||
'execute immediate \'insert into "fakeTable" ("value1", "value2", "value3", "value4") values ' +
|
'execute immediate \'insert into "fakeTable" ("value1", "value2", "value3", "value4") values ' +
|
||||||
'(:1, DEFAULT, DEFAULT, DEFAULT)\' using ?;end;'
|
"(:1, DEFAULT, DEFAULT, DEFAULT)' using ?;end;"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -27,19 +27,18 @@ describe('Oracledb dialect', () => {
|
|||||||
|
|
||||||
describe('#4869 inserting Buffer', async () => {
|
describe('#4869 inserting Buffer', async () => {
|
||||||
it('.toSQL().toNative() generates correct sql and bindings for INSERT of Buffer', async () => {
|
it('.toSQL().toNative() generates correct sql and bindings for INSERT of Buffer', async () => {
|
||||||
const b = Buffer.from('hello', 'utf-8')
|
const b = Buffer.from('hello', 'utf-8');
|
||||||
const query = knex('table1').insert({ value: b })
|
const query = knex('table1').insert({ value: b });
|
||||||
const queryObj = query.toSQL().toNative()
|
const queryObj = query.toSQL().toNative();
|
||||||
// Ensure we have two bindings, before fix for #4869 there would only have been one due
|
// Ensure we have two bindings, before fix for #4869 there would only have been one due
|
||||||
// to silent dropping of the Buffer.
|
// to silent dropping of the Buffer.
|
||||||
expect(queryObj.bindings.length).to.eql(2)
|
expect(queryObj.bindings.length).to.eql(2);
|
||||||
expect(queryObj).to.eql({
|
expect(queryObj).to.eql({
|
||||||
sql: 'insert into "table1" ("value") values (:1) returning "value" into :2',
|
sql: 'insert into "table1" ("value") values (:1) returning "value" into :2',
|
||||||
bindings: [b, { type: 2019, dir: 3003 }],
|
bindings: [b, { type: 2019, dir: 3003 }],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const child_process = require("child_process");
|
const child_process = require('child_process');
|
||||||
const rimrafSync = require('rimraf').sync;
|
const rimrafSync = require('rimraf').sync;
|
||||||
|
|
||||||
function assertExec(cmd, desc) {
|
function assertExec(cmd, desc) {
|
||||||
@ -11,9 +11,7 @@ function assertExec(cmd, desc) {
|
|||||||
let stderr = '';
|
let stderr = '';
|
||||||
let stdout = '';
|
let stdout = '';
|
||||||
const bin = child_process.exec(cmd);
|
const bin = child_process.exec(cmd);
|
||||||
bin.on('error', (msg, code) =>
|
bin.on('error', (msg, code) => reject(Error(desc + ' FAIL. ' + stderr)));
|
||||||
reject(Error(desc + ' FAIL. ' + stderr))
|
|
||||||
);
|
|
||||||
bin.on('cmdEnd', (cmd) => resolve({ cmd, stdout, stderr }));
|
bin.on('cmdEnd', (cmd) => resolve({ cmd, stdout, stderr }));
|
||||||
bin.on('stdout', (data) => (stdout += data.toString()));
|
bin.on('stdout', (data) => (stdout += data.toString()));
|
||||||
bin.on('stderr', (data) => (stderr += data.toString()));
|
bin.on('stderr', (data) => (stderr += data.toString()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user