diff --git a/actions/killALL.js b/actions/killALL.js index b8905fa..789253d 100644 --- a/actions/killALL.js +++ b/actions/killALL.js @@ -2,6 +2,8 @@ const shell = require('shelljs'); +const { EOL } = require('os'); + const npath = require('../utils/nginxPath'); const conf = require('../utils/nginxConf'); @@ -20,6 +22,12 @@ function killALL () { shell.ln('-sf', npath.confD() + "default.conf", npath.enabledSites() + "default.conf"); // Symlink the default.conf file from confD to sites-enabled + console.log("All servers were killed and reverted to default."); + console.log(EOL + [ + "A backup of your old servers.up is " + + "saved in /etc/up-serve/servers.bak.up.", + "Check this if you need to." + ].join(EOL) + EOL); } function noKill () { @@ -27,4 +35,4 @@ function noKill () { } module.exports.kill = killALL; -module.exports.noKill = noKill; \ No newline at end of file +module.exports.noKill = noKill; diff --git a/actions/killAllConfirm.js b/actions/killAllConfirm.js index 1d8a8e8..d6cc380 100644 --- a/actions/killAllConfirm.js +++ b/actions/killAllConfirm.js @@ -1,21 +1,18 @@ 'use strict'; -const readline = require('readline'); +const readlineSync = require('readline-sync'); const killALL = require('./killALL').kill; -const noKill = require('./killALL').noKill; +const { noKill } = require('./killALL'); function killAllConfirm() { - console.log("\nThis action will destroy all nginx servers and return to default configuration.\nAre you sure you want to do this?" + "\nConfirm y[es] / n[o]:"); - const rl = readline.createInterface({ input: process.stdin }); - - const line = () => new Promise(resolve => rl.once('line', resolve)); - - line().then(line => { - line.trim(); - if((/^(y(es)?|n(o)?)$/).test(line)) { - line == "y" || "yes" ? killALL() : noKill(); - } - }); + console.log("\nThis action will destroy all nginx servers and return " + + "to default configuration."); + if (readlineSync.keyInYN("Are you sure you want to do this?")) { + killALL(); + } + else { + noKill(); + } } module.exports = killAllConfirm; \ No newline at end of file diff --git a/assets/tlds.txt b/assets/tlds.txt index c87ced8..2df92a0 100644 --- a/assets/tlds.txt +++ b/assets/tlds.txt @@ -1,4 +1,4 @@ -# Version 2017110701, Last Updated Wed Nov 8 07:07:02 2017 UTC +# Version 2017111900, Last Updated Sun Nov 19 07:07:01 2017 UTC AAA AARP ABARTH diff --git a/index.js b/index.js index b7efe31..52d1550 100755 --- a/index.js +++ b/index.js @@ -92,11 +92,6 @@ program .action(function() { //new Promise(resolve => killed\killAllConfirm(); killAllConfirm(); - console.log(EOL + [ - "A backup of your old servers.up is " + - "saved in /etc/up-serve/servers.bak.up.", - "Check this if you need to." - ].join(EOL) + EOL); }); program