From bf85c6bd7cce9cc9c8f6969a71d1f70735005523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Brauer?= Date: Mon, 10 Jan 2022 10:49:38 +0000 Subject: [PATCH] fix(lambda): replace package prompt with readline To get around the colors dependency in prompt --- packages/lambda/lib/prompt.js | 24 ++++++++++-------------- packages/lambda/package.json | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/lambda/lib/prompt.js b/packages/lambda/lib/prompt.js index 632e44cbb..08b5fc1d3 100644 --- a/packages/lambda/lib/prompt.js +++ b/packages/lambda/lib/prompt.js @@ -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)); }); }); }; diff --git a/packages/lambda/package.json b/packages/lambda/package.json index fc2c1e0f7..add7a64b8 100644 --- a/packages/lambda/package.json +++ b/packages/lambda/package.json @@ -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",