How to use exit - 10 common examples

To help you get started, we’ve selected a few exit 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 MoOx / postcss-cssnext / src / bin.js View on Github external
config.from = input
config.to = output

if (output) {
  mkdirp.sync(path.dirname(output))
}

// init & adjust watcher with postcss-import dependencies
let watcher
if (config.watch) {
  if (!input || !output) {
    console.error(
      color.red("--watch option need both <input> &amp; <output> files to work")
    )
    exit(3)
  }

  watcher = require("chokidar").watch(input, {ignoreInitial: true})

  if (verbose) {
    log(color.cyan("Watching"), input)
  }

  // https://github.com/paulmillr/chokidar/issues/288
  // ready event might not be triggered at all
  // watcher.on("ready", function() {
  //   if (verbose) {
  //     log(color.cyan("Watcher ready"), input)
  //   }
  // })
</output>
github MoOx / postcss-cssnext / src / bin.js View on Github external
config.sourcemap = program.sourcemap
}
if ("compress" in program) {
  config.compress = program.compress
}
if ("watch" in program) {
  config.watch = program.watch
}

const input = program.args[0] ? path.resolve(program.args[0]) : null
const output = program.args[1] ? path.resolve(program.args[1]) : null
const verbose = program.verbose

if (input &amp;&amp; !fs.existsSync(input)) {
  console.error(color.red("Unable to read file"), input)
  exit(1)
}

config.from = input
config.to = output

if (output) {
  mkdirp.sync(path.dirname(output))
}

// init &amp; adjust watcher with postcss-import dependencies
let watcher
if (config.watch) {
  if (!input || !output) {
    console.error(
      color.red("--watch option need both <input> &amp; <output> files to work")
    )</output>
github tommy351 / kosko / packages / template / src / cli.ts View on Github external
}

  for (const key of Object.keys(options)) {
    cmd.option(key, options[key]);
  }

  try {
    const args = cmd.parse(argv);
    const result = await template.generate(args);

    await writeFiles(args.cwd, result.files);
    signale.success("%d files are generated", result.files.length);
  } catch (err) {
    // tslint:disable-next-line:no-console
    console.error(err);
    exit(1);
    throw err;
  }
}
github nuxt / typescript / test / setup.js View on Github external
function errorTrap (error) {
  process.stderr.write('\n' + error.stack + '\n')
  exit(1)
}
github elijahmanor / cross-var / src / index.js View on Github external
const proc = exec( command, ( error, stdout, stderr ) => {
        if ( error ) {
            console.error( `exec error: ${ error }` );
            return;
        }
        process.stdout.write( stdout );
        process.stderr.write( stderr );
        exit(proc.code);
    });
} else {
github MoOx / postcss-cssnext / src / bin.js View on Github external
}
    }
    catch (e) {
      console.error()
      console.error(color.bold("cssnext encounters an error:"))
      console.error()
      console.error(color.red(e.message))
      if (e.stack) {
        console.error(e.stack.split("\n").slice(1).join("\n").grey)
        console.error()
      }
      console.error("If this error looks like a bug, please report it here:")
      console.error(color.grey("❯ ") + color.cyan(pkg.bugs.url))
      console.error()
      if (!config.watch) {
        exit(2)
      }
    }
  })
}
github milesj / boost / packages / core / src / Console.ts View on Github external
handleFailure = (error: Error) => {
    this.start();
    this.debug('Uncaught exception or unresolved promise handled');
    this.stop(error);

    exit(2);
  };
github ionic-team / stencil / src / cli / task-serve.ts View on Github external
process.once('SIGINT', () => {
    config.sys.destroy();
    devServer && devServer.close();
    exit(0);
  });
}

exit

A replacement for process.exit that ensures stdio are fully drained before exiting.

MIT
Latest version published 11 years ago

Package Health Score

67 / 100
Full package analysis

Popular exit functions