From 5bc25b561d10a221b0cb39865c0b5e87e1a76ef5 Mon Sep 17 00:00:00 2001 From: Thomas Berger Date: Tue, 19 Jun 2018 11:18:11 +0200 Subject: [PATCH 1/2] use prompt override --- upgrade.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/upgrade.js b/upgrade.js index c70d3f1cb4..b089d4f584 100644 --- a/upgrade.js +++ b/upgrade.js @@ -2,6 +2,7 @@ var _ = require('underscore'); var async = require('async'); var chalk = require('chalk'); var fs = require('fs-extra'); +var prompt = require('prompt'); var optimist = require('optimist'); var path = require('path'); var semver = require('semver'); @@ -13,6 +14,8 @@ var origin = require('./lib/application'); var OutputConstants = require('./lib/outputmanager').Constants; var installHelpers = require('./lib/installHelpers'); +var IS_INTERACTIVE = process.argv.length === 2; + var DEFAULT_USER_AGENT = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36'; var app = origin(); @@ -24,6 +27,9 @@ start(); function start() { // don't show any logger messages in the console logger.level('console','error'); + + prompt.override = optimist.argv; + // start the server first app.run({ skipVersionCheck: true, skipStartLog: true }); app.on('serverStarted', function() { @@ -74,14 +80,16 @@ function getUserInput() { } } }; - console.log(`\nThis script will update the ${app.polyglot.t('app.productname')} and/or Adapt Framework. Would you like to continue?`); + if (IS_INTERACTIVE) { + console.log(`\nThis script will update the ${app.polyglot.t('app.productname')} and/or Adapt Framework. Would you like to continue?`); + } installHelpers.getInput(confirmProperties, function(result) { - if(!result.continue) { + if(!installHelpers.inputHelpers.toBoolean(result.continue)) { return installHelpers.exit(); } installHelpers.getInput(upgradeProperties, function(result) { console.log(''); - if(result.updateAutomatically) { + if(installHelpers.inputHelpers.toBoolean(result.updateAutomatically)) { return checkForUpdates(function(error, updateData) { if(error) { return installHelpers.exit(1, error); From 559063afce0f8ad09a76a3c958bd1e89ade1a4a0 Mon Sep 17 00:00:00 2001 From: Thomas Berger Date: Wed, 20 Jun 2018 16:43:34 +0200 Subject: [PATCH 2/2] do not convert boolean --- lib/installHelpers.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/installHelpers.js b/lib/installHelpers.js index 1c24387d56..7bc9fc7ef9 100644 --- a/lib/installHelpers.js +++ b/lib/installHelpers.js @@ -27,7 +27,8 @@ var inputHelpers = { numberValidator: /^[0-9]+\W*$/, alphanumValidator: /^[A-Za-z0-9_-]+\W*$/, toBoolean: function(v) { - if(/(Y|y)[es]*/.test(v)) return true; + if (typeof v === 'boolean') return v; + if (/(Y|y)[es]*/.test(v)) return true; return false; }, passwordBefore: function(v) {