Skip to content

Commit b92a9a9

Browse files
committed
promisify prompt.get
1 parent 0ff93b6 commit b92a9a9

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/prompt.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,16 @@ prompt.history = function (search) {
192192
// Gets input from the user via stdin for the specified message(s) `msg`.
193193
//
194194
prompt.get = function (schema, callback) {
195+
if (typeof callback === 'function') return prompt._get(schema, callback);
196+
197+
return new Promise(function (resolve, reject) {
198+
prompt._get(schema, function (err, result) {
199+
return err ? reject(err) : resolve(result);
200+
});
201+
});
202+
};
203+
204+
prompt._get = function (schema, callback) {
195205
//
196206
// Transforms a full JSON-schema into an array describing path and sub-schemas.
197207
// Used for iteration purposes.

0 commit comments

Comments
 (0)