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 2, 2020
1 parent 0ff93b6 commit 8e1ac94
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ 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((resolve, reject) => {
prompt._get(schema, (err, result) => 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 8e1ac94

Please sign in to comment.