prompt({ type: 'input', name: 'color', message: 'Favorite color?' }) .then(answers => { console.info(answers); process.exit(0); });
constructor(options = {}) { super(options); this.emptyError = options.emptyError || 'No items were selected'; this.term = process.env.TERM_PROGRAM; if (!this.options.header) { let header = ['', '4 - Strongly Agree', '3 - Agree', '2 - Neutral', '1 - Disagree', '0 - Strongly Disagree', '']; header = header.map(ele => this.styles.muted(ele)); this.state.header = header.join('\n '); } }
const onExit = (quit, code) => { if (called) return; called = true; fns.forEach(fn => fn()); if (quit === true) { process.exit(128 + code); } }
prompt.on('cancel', () => process.exit());
process.nextTick(() => fn().then(resolve).catch(reject));
constructor(options = {}) { super(); this.name = options.name; this.type = options.type; this.options = options; theme(this); timer(this); this.state = new State(this); this.initial = [options.initial, options.default].find(v => v != null); this.stdout = options.stdout || process.stdout; this.stdin = options.stdin || process.stdin; this.scale = options.scale || 1; this.term = this.options.term || process.env.TERM_PROGRAM; this.margin = margin(this.options.margin); this.setMaxListeners(0); setOptions(this); }
constructor(prompt) { let options = prompt.options; define(this, '_prompt', prompt); this.type = prompt.type; this.name = prompt.name; this.message = ''; this.header = ''; this.footer = ''; this.error = ''; this.hint = ''; this.input = ''; this.cursor = 0; this.index = 0; this.lines = 0; this.tick = 0; this.prompt = ''; this.buffer = ''; this.width = width(options.stdout || process.stdout); Object.assign(this, options); this.name = this.name || this.message; this.message = this.message || this.name; this.symbols = prompt.symbols; this.styles = prompt.styles; this.required = new Set(); this.cancelled = false; this.submitted = false; }
monitorHandler(agent: MonitorAgent, msg: any, cb: MonitorCallback) { let serverId = agent.id; let pid = process.pid; let params: PsParam = { serverId: serverId, pid: String(pid) }; monitor.psmonitor.getPsInfo(params, function (err: Error, data: any) { agent.notify(NodeInfoModule.moduleId, { serverId: agent.id, body: data }); }); }
stop(force: boolean, cb: () => void) { this.switcher.close(); this.listeningServer.close(); process.nextTick(cb); }
stop(force: boolean, cb: () => void) { for (let type in this.watchers) { this.watchers[type].close(); } this.watchers = {}; process.nextTick(cb); }
/** * Remote component lifecycle function * * @param {Boolean} force whether stop the component immediately * @param {Function} cb * @return {Void} */ stop(force: boolean, cb: () => void) { this.remote.stop(force); process.nextTick(cb); }
process.on('uncaughtException', function (err) { /* temporary code */ console.error(' Caught exception: ' + err.stack); if (!!robot && !!robot.agent) { // robot.agent.socket.emit('crash', err.stack); } fs.appendFile('./log/.log', err.stack, function (err) { }); /* temporary code */ });
/** * Exit with the given `str`. * * @param {String} str */ export function abort(str: string) { console.error(str); process.exit(1); }
/** * Component lifecycle function * * @param {Boolean} force whether stop the component immediately * @param {Function} cb * @return {Void} */ stop(force: boolean, cb: () => void) { this.server.stop(); process.nextTick(cb); }