Skip to content

Commit

Permalink
fix(lambda): replace package prompt with readline
Browse files Browse the repository at this point in the history
To get around the colors dependency in prompt
  • Loading branch information
ZauberNerd committed Jan 11, 2022
1 parent d06751e commit bf85c6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/lambda/lib/prompt.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
'use strict';

var prompt = require('prompt');
var chalk = require('chalk');
var readline = require('readline');

module.exports = function (message) {
var yesno = {
name: 'yesno',
message: message,
validator: /y[es]*|n[o]?/i,
warning: 'Must respond yes or no',
default: 'no',
};
return new Promise(function (resolve) {
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});

return new Promise(function (resolve, reject) {
prompt.get(yesno, function (error, answer) {
if (error) {
return reject(error);
}
resolve(answer.yesno[0] === 'y');
rl.question(`${message} ${chalk.gray('yes/[no]')}`, function (answer) {
rl.close();
resolve(/^y(es)?$/i.test(answer));
});
});
};
1 change: 1 addition & 0 deletions packages/lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"archiver": "^5.0.0",
"aws-sdk": "^2.546.0",
"chalk": "^4.0.0",
"globby": "^11.0.0",
"hops-bootstrap": "16.0.0-nightly.0",
"hops-config": "16.0.0-nightly.0",
Expand Down

0 comments on commit bf85c6b

Please sign in to comment.