const formatSource = async () => { console.log(chalk.reset('Formatting source files...')); try { const sourceFilePaths = await getSourceFilePaths(); const formattedPaths = await Promise.all(sourceFilePaths.map(filePath => formatFile(filePath, filePath))); console.log(chalk.green(`Formatted ${formattedPaths.length} files.`)); } catch (error) { console.log(chalk.red('Problem formatting file:\n'), chalk.reset(error)); process.exit(1); } }
runner(process.argv.slice(2), { templates: defaultTemplates, cwd: process.cwd(), logger: new Logger(console.log.bind(console)), debug: !!process.env.DEBUG, exec: (action, body) => { const opts = body && body.length > 0 ? { input: body } : {} return require('execa').command(action, { ...opts, shell: true }) }, createPrompter: () => require('enquirer'), }).then(({ success }) => process.exit(success ? 0 : 1))
enforcePrerequisites() .then(migrateData) .then(startWebServer) .catch(error => { console.log(chalk.red('Failed to start Flood:')); console.trace(error); process.exit(1); });
program.on('--help', () => { console.log(` Get started: $ postgraphile $ postgraphile -c postgres://localhost/my_db $ postgraphile --connection postgres://user:pass@localhost/my_db --schema my_schema --watch --dynamic-json `); process.exit(0); });
async function run() { const connection = await createConnection(config.db); await addColumn(connection); // tslint:disable-next-line: no-console console.log('----------------- all done -----------------'); process.exit(0); }()
function exitWithErrorMessage(message: string): never { console.error(message); console.error(); console.error('For help, run `postgraphile --help`'); process.exit(1); }
Promise.resolve(buildCmds).each(cmd => shell.sh(cmd.run, cmd.opts)) // Move the built assetz .then(() => Promise.resolve(distCopy)).each(item => fs.copySync(item.src, item.dest, {overwrite: true})) // Catch errors and exit .catch(err => { log.error(err); process.exit(444); })
function help(status) { const print = (status === 0) ? console.log : console.error print("usage: " + basename(process.argv[1]) + " [--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|...|--ecma2015|--ecma2016|--ecma2017|--ecma2018|...]") print(" [--tokenize] [--locations] [---allow-hash-bang] [--compact] [--silent] [--module] [--help] [--] [infile]") process.exit(status) }
async function run() { const connection = await createConnection(config.db); await insertAdmin(connection); await insertCrawler(connection); logger.info({ message: 'init db done' }); process.exit(0); }()
process.on('uncaughtException', async err => { console.error('Uncaught exception', err); try { await new Promise(resolve => Raven.captureException(err, resolve)); } catch (err) { console.error('Raven error', err); } finally { process.exit(1); } });
// Handle both user-initiated (SIGINT) and normal termination. process.on( 'SIGINT', function () { handleExit(); process.exit(); } );
process.on('unhandledRejection', async err => { console.error('Unhandled rejection', err); try { await new Promise(resolve => Raven.captureException(err, resolve)); } catch (err) { console.error('Raven error', err); } finally { process.exit(1); } });