Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
child.on('close', function (code) {
process.exitCode = code; // Sets expected exit code without forcing exit prior to buffers flushing.
code && console.log("child process exited with code ", code);
});
program.command('lintjs [eslintParams...]').description('使用felint检测js代码').option('--exitcode', '使用exitcode').allowUnknownOption().action(function (eslintParams, options) {
let eslintPath = `${process.cwd()}/node_modules/eslint/lib/cli.js`;
let eslintCli;
try {
eslintCli = require(eslintPath);
} catch (e) {
console.log('你尚未安装eslint');
process.exitCode = 0;
return;
}
let params = process.argv.slice(0);
params.splice(2, 1);
if (options.exitcode) {
// 处理params
params.splice(params.indexOf('--exitcode'), 1);
}
var exitCode = eslintCli.execute(params);
if (options.exitcode) {
process.exitCode = exitCode;
}
});
summary() {
if (this.total === 0) {
console.log('No checks run.');
} else {
let overallPassRate = (this.passed / this.total * 100.0).toFixed(1);
// set exitCode to 1 if anything failed
if (this.failed > 0) process.exitCode = 1;
console.log();
console.log(chalk.underline('Summary'));
console.log();
console.log(chalk.gray(`\t${overallPassRate}% of all checks passed.`));
console.log(`\t${chalk.green(this.passed)} ${chalk.gray('passed ·')} ${chalk.red(this.failed)} ${chalk.gray('failed')}`);
}
}
.action(function(eslintParams, options) {
let eslintPath = `${process.cwd()}/node_modules/eslint/lib/cli.js`;
let eslintCli;
try {
eslintCli = require(eslintPath);
} catch (e) {
console.log('你尚未安装eslint');
process.exitCode = 0;
return;
}
let params = process.argv.slice(0);
params.splice(2, 1);
if (options.exitcode) {
// 处理params
params.splice(params.indexOf('--exitcode'), 1);
}
var exitCode = eslintCli.execute(params);
if (options.exitcode) {
process.exitCode = exitCode;
}
});
lib.parseForUnusedImports(inputFile, function (err, unusedImports) {
if(err) {
console.error(err);
return;
}
// We will exit with code 1 when unused imports were found.
// Code is 0 otherwise.
process.exitCode = unusedImports.length == 0 ? 0 : 1;
// Nothing to do here, the file looks fine
if(unusedImports.length == 0) {
return;
}
// Output JSON if raw mode is requested
if(argv.r) {
console.log(unusedImports);
return;
}
// Output vim 'matchadd' code if vim mode is requested
if(argv.v) {
lib.outputVim(unusedImports);
return;
var process = require('process');
var json = require('json');
console.log(json.encode(process.env));
process.exitCode = 4;
var process = require('process');
var json = require('json');
console.log(json.encode(process.argv));
process.exitCode = 2;
this.addListener("writtenApplications", e => {
if (this.argv.verbose) {
qx.tool.compiler.Console.log("\nCompleted all applications, libraries used are:");
Object.values(this.__libraries).forEach(lib => qx.tool.compiler.Console.log(` ${lib.getNamespace()} (${lib.getRootDir()})`));
}
});
await this._loadConfigAndStartMaking();
if (!this.argv.watch) {
let success = this.__makers.every(maker => maker.getSuccess());
let hasWarnings = this.__makers.every(maker => maker.getHasWarnings());
if (success && (hasWarnings && this.argv.warnAsError)) {
success = false;
}
process.exitCode = success ? 0 : 1;
}
},
trace = args['trace'];
} else if (args['trace'] && typeof(args['trace']) !== 'string' && args['trace'].length == 0) {
errorLogger.log(`--trace must be a string`);
process.exitCode = 1;
return;
}
try {
if (isFinite(args['max-time']) === false && args['max-time'] > 0) {
errorLogger.log(`--max-time can only be a number greater than 0`);
process.exitCode = 1;
return;
}
} catch (err) {
errorLogger.log(`--max-time can only be a number greater than 0`, err);
process.exitCode = 1;
return;
}
try {
url = new URL(args['url'] || args['_'][0]);
} catch (err) {
errorLogger.log(`--url or default value is not a valid URL`);
process.exitCode = 1;
return;
}
try {
if (args['e']) {
referer = new URL(args['e']).href;
}
} catch (err) {
main().catch((err) => {
process.exitCode = 1;
if (err instanceof DebugError) {
logger.error(err.stack);
} else {
logger.error(err.message || 'unknown error!');
}
});
}