diff --git a/src/util.ts b/src/util.ts index 2954ce1..a4862a1 100644 --- a/src/util.ts +++ b/src/util.ts @@ -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 { + return nfcall(_read, assign({ prompt }, options)) + .spread(r => r); } \ No newline at end of file