How to use the process.exitCode function in process

To help you get started, we’ve selected a few process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tunnelvisionlabs / antlr4ts / tool / index.js View on Github external
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);
});
github youzan / felint / lib / index.js View on Github external
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;
    }
});
github ottomatica / opunit / lib / inspect / report.js View on Github external
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')}`);
        }
    }
github youzan / felint / src / index.js View on Github external
.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;
        }
    });
github fourcube / unused / src / index.js View on Github external
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;
github fibjs / fibjs / test / process / exec4.js View on Github external
var process = require('process');
var json = require('json');

console.log(json.encode(process.env));
process.exitCode = 4;
github fibjs / fibjs / test / process / exec2.js View on Github external
var process = require('process');
var json = require('json');

console.log(json.encode(process.argv));
process.exitCode = 2;
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / cli / commands / Compile.js View on Github external
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;
      }
    },
github PaulKinlan / domcurl / index.js View on Github external
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) {
github autoapply / autoapply / bin / autoapply.js View on Github external
main().catch((err) => {
        process.exitCode = 1;
        if (err instanceof DebugError) {
            logger.error(err.stack);
        } else {
            logger.error(err.message || 'unknown error!');
        }
    });
}