Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use prompt override #1992

Merged
merged 5 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/installHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 11 additions & 3 deletions upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();

Expand All @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down