Skip to content

Commit

Permalink
promisify prompt.get
Browse files Browse the repository at this point in the history
  • Loading branch information
caub committed Mar 3, 2020
1 parent 0ff93b6 commit b92a9a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/prompt.js
Expand Up @@ -192,6 +192,16 @@ prompt.history = function (search) {
// Gets input from the user via stdin for the specified message(s) `msg`.
//
prompt.get = function (schema, callback) {
if (typeof callback === 'function') return prompt._get(schema, callback);

return new Promise(function (resolve, reject) {
prompt._get(schema, function (err, result) {
return err ? reject(err) : resolve(result);
});
});
};

prompt._get = function (schema, callback) {
//
// Transforms a full JSON-schema into an array describing path and sub-schemas.
// Used for iteration purposes.
Expand Down

0 comments on commit b92a9a9

Please sign in to comment.