add read util
This commit is contained in:
parent
854e73e592
commit
62a77d567f
1 changed files with 8 additions and 1 deletions
|
@ -1,4 +1,6 @@
|
|||
import { Promise } from 'q';
|
||||
import { Promise, nfcall } from 'q';
|
||||
import { assign } from 'lodash';
|
||||
import _read = require('read');
|
||||
|
||||
export function fatal(message: any, ...args: any[]) {
|
||||
if (message instanceof Error && /^cancell?ed$/i.test(message.message)) {
|
||||
|
@ -7,4 +9,9 @@ export function fatal(message: any, ...args: any[]) {
|
|||
|
||||
console.error('Error:', message, ...args);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
export function read(prompt: string, options: _read.Options = {}): Promise<string> {
|
||||
return nfcall<string>(_read, assign({ prompt }, options))
|
||||
.spread(r => r);
|
||||
}
|
Loading…
Add table
Reference in a new issue