How to use the process.exit 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 PeterCxy / yarmd / src / main.js View on Github external
function main() {
    if (argv.help) {
        console.log(optimist.help())
        process.exit(0)
    }
    
    if (argv._.length == 0 || argv._[0] == null || argv._[0] == "") {
        logger.error('No URL provided.')
        console.log(optimist.help())
        process.exit(1)
    }

    argv.directory = path.resolve(argv.directory)
    if (!fs.existsSync(argv.directory)) {
        logger.error(`Directory ${argv.directory} does not exist.`)
        process.exit(1)
    }

    // Validate the URL first
    let url = argv._[0].trim()
    if (!url.endsWith('/')) {
        logger.info('Adding a trailing / automatically.')
        url += '/'
    }
    url = parseURL(url)
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / cli / commands / add / Script.js View on Github external
throw new qx.tool.utils.Utils.UserError("File doesn't seem to be a javascript file.");
      }
      if (!await fs.existsAsync(script_path) && !this.argv.undo) {
        throw new qx.tool.utils.Utils.UserError(`File does not exist: ${script_path}`);
      }
      if (await fs.existsAsync(resource_file_path) && !this.argv.undo) {
        if (!this.argv.noninteractive) {
          let question = {
            type: "confirm",
            name: "doOverwrite",
            message: `Script already exists and will be overwritten. Do you want to proceed?`,
            default: "y"
          };
          let answer = await inquirer.prompt(question);
          if (!answer.doOverwrite) {
            process.exit(0);
          }
        }
      }
      // check manifest structure
      let script_list = manifestModel.getValue("externalResources.script") || [];
      if (this.argv.undo) {
        // undo, i.e. remove file from resource folder and Manifest
        if (script_list.includes(external_res_path)) {
          script_list = script_list.filter(elem => elem !== external_res_path);
        }
        if (await fs.existsAsync(resource_file_path)) {
          await fs.unlinkAsync(resource_file_path);
        }
      } else {
        // copy script to app resources and add to manifest
        if (!await fs.existsAsync(resource_dir_path)) {
github Financial-Times / polyfill-service / polyfills / fetch / update.task.js View on Github external
/* eslint-env node */
'use strict';

const fs = require('fs');
const diff = require('diff');
const process = require('process');
const path = require('path');

const polyfill = fs.readFileSync(path.join(__dirname, './polyfill.js'), 'utf8');
const patch = fs.readFileSync(path.join(__dirname, './patch.jsdiff'), 'utf8');

const patched = diff.applyPatch(polyfill, patch);

if (patched === false) process.exit(1);
fs.writeFileSync(path.join(__dirname, './polyfill.js'), patched);
github cboulanger / bibliograph / test / playwright / Application.js View on Github external
error(message) {
    console.error(`not ok - ${message}`);
    process.exit(1);
  }
github ETCDEVTeam / emerald-wallet / packages / desktop / scripts / download-emerald.js View on Github external
.then((result) => {
    if (result === 'exists') {
      console.log('emerald exists.');
    }
    process.exit(0);
  })
  .catch((error) => {
github maxharlow / reconcile / cli.js View on Github external
.option('p', { alias: 'parameters', type: 'string', describe: 'Parameters to be passed to the reconciler, either in Json or Yaml' })
        .option('r', { alias: 'retries', type: 'number', nargs: 1, describe: 'Number of times a request should be retried', default: 5 })
        .option('c', { alias: 'cache', type: 'boolean', describe: 'Whether to cache HTTP requests', default: false })
        .option('j', { alias: 'join', type: 'string', describe: 'Whether to include unmatched rows (outer) or not (inner)', choices: ['outer', 'inner'], default: 'inner' })
        .help('?').alias('?', 'help')
        .version().alias('v', 'version')
    reconcilers.forEach(command => {
        const reconciler = require('./reconcile-' + command)
        const commandArgs = args => args
            .usage(`Usage: reconcile ${command} `)
            .demand(1, '')
            .positional('filename', { type: 'string', describe: 'The input file to process' })
            .epilog(display(reconciler.details))
        interface.command(command, '', commandArgs)
    })
    if (interface.argv['get-yargs-completions']) Process.exit(0)
    if (interface.argv._.length === 0) Yargs.showHelp().exit(0)
    try {
        const command = interface.argv._[0]
        const filename = interface.argv._[1]
        const parameters = await parse(interface.argv.parameters)
        const retries = interface.argv.retries
        const cache = interface.argv.cache
        const join = interface.argv.join
        if (!reconcilers.includes(command)) throw new Error(`${command}: reconciler not found`)
        if (filename === '-') throw new Error('reading from standard input not supported')
        const exists = await FSExtra.pathExists(filename)
        if (!exists) throw new Error(`${filename}: could not find file`)
        console.error('Starting up...')
        const total = await reconcile.length(filename)
        reconcile.run(command, filename, parameters, retries, cache, join, alert)
            .tap(ticker('Working...', total))
github uber-archive / idl / bin / idl.js View on Github external
resolveCwd(conf.cwd, function onCwd(cwdErr, cwd) {
        if (cwdErr) {
            console.error('ERR: ' + cwdErr);
            process.exit(1);
        }
        conf.cwd = cwd;

        IDL(conf).processArgs(function onFini(err, text) {
            if (err) {
                console.error('ERR: ' + err);
                process.exit(1);
            }

            if (text) {
                console.log(text.toString());
            }
        });
    });
}
github stream-labs / obs-studio-node / scripts / build-obs.ts View on Github external
function finishConfigure(error: any, stdout: string, stderr: string) {
    if (error) {
        console.log(`Failed to execute cmake: ${error}`);
        console.log(`${stdout}`);
        console.log(`${stderr}`);
        process.exit(1);
    }

    obsBuild();
}
github FabMo / FabMo-Engine / log.js View on Github external
try {
	    	saveLogBuffer(filename);
	    	_log.info("Log saved to " + filename);
		if(flightRecorder) {
			flightRecorder.save(flight_fn, function(err, data) {
			rotateLogs(PERSISTENT_LOG_COUNT, function() {
				if(options.exit) {
					_log.info("Exiting via process.exit()...");
					process.exit();
				}
			});
			});
		} else {
			if(options.exit) {
				_log.info("Exiting via process.exit()...");
				process.exit();
			}
		}
	    	return;
    	} catch(e) {
	    	_log.error("Could not save log to " + filename);
	    	_log.error(e);
    	}
	    if (options.exit) {
		_log.info("Exiting via process.exit()...");
	    	process.exit();
	    }
	}
}