Remove yesno node module
This commit is contained in:
9
package-lock.json
generated
9
package-lock.json
generated
@@ -63,8 +63,7 @@
|
||||
"expect.js": "*",
|
||||
"mocha": "^11.7.5",
|
||||
"nock": "^14.0.10",
|
||||
"ssh2": "^1.17.0",
|
||||
"yesno": "^0.4.0"
|
||||
"ssh2": "^1.17.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@aashutoshrathi/word-wrap": {
|
||||
@@ -8683,12 +8682,6 @@
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/yesno": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/yesno/-/yesno-0.4.0.tgz",
|
||||
"integrity": "sha512-tdBxmHvbXPBKYIg81bMCB7bVeDmHkRzk5rVJyYYXurwKkHq/MCd8rz4HSJUP7hW0H2NlXiq8IFiWvYKEHhlotA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/yocto-queue": {
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
|
||||
@@ -67,8 +67,7 @@
|
||||
"expect.js": "*",
|
||||
"mocha": "^11.7.5",
|
||||
"nock": "^14.0.10",
|
||||
"ssh2": "^1.17.0",
|
||||
"yesno": "^0.4.0"
|
||||
"ssh2": "^1.17.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./run-tests"
|
||||
|
||||
@@ -15,9 +15,49 @@ const assert = require('assert'),
|
||||
Table = require('easy-table'),
|
||||
url = require('url'),
|
||||
util = require('util'),
|
||||
yesno = require('yesno'),
|
||||
readline = require('readline'),
|
||||
_ = require('../src/underscore.js');
|
||||
|
||||
// slightly simplified from https://github.com/tcql/node-yesno/blob/master/yesno.js
|
||||
async function yesno({ question, defaultValue, yesValues, noValues }) {
|
||||
const options = {
|
||||
yes: [ 'yes', 'y' ],
|
||||
no: [ 'no', 'n' ]
|
||||
};
|
||||
|
||||
const yValues = (yesValues || options.yes).map((v) => v.toLowerCase());
|
||||
const nValues = (noValues || options.no).map((v) => v.toLowerCase());
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
rl.question(question + ' ', async function (answer) {
|
||||
rl.close();
|
||||
|
||||
const cleaned = answer.trim().toLowerCase();
|
||||
|
||||
if (cleaned == '' && defaultValue != null)
|
||||
return resolve(defaultValue);
|
||||
|
||||
if (yValues.indexOf(cleaned) >= 0)
|
||||
return resolve(true);
|
||||
|
||||
if (nValues.indexOf(cleaned) >= 0)
|
||||
return resolve(false);
|
||||
|
||||
process.stdout.write('\nInvalid Response.\n');
|
||||
process.stdout.write('Answer either yes : (' + (yesValues || options.yes).join(', ') + ') \n');
|
||||
process.stdout.write('Or no: (' + (noValues || options.no).join(', ') + ') \n\n');
|
||||
|
||||
const result = await yesno({ question, defaultValue, yesValues, noValues });
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const ENVIRONMENTS = {
|
||||
'dev': {
|
||||
tag: 'dev',
|
||||
@@ -470,6 +510,9 @@ async function cleanup(options) {
|
||||
const ok = await yesno({ question: 'Really delete those unused release assets? [y/N]', defaultValue: null });
|
||||
if (!ok) return exit();
|
||||
|
||||
console.log('---', ok)
|
||||
return
|
||||
|
||||
const escapedAssets = unusedAssets.map(asset => `'/home/ubuntu/releases/${asset}'`).join(' ');
|
||||
execSync(`ssh ubuntu@${env.releasesServer} "rm ${escapedAssets}"`, { stdio: [ null, process.stdout, process.stderr ] } );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user