Use console.log instead of process.stdout.write (#6123)

* Use console.log instead of process.stdout.write

* Don't break the installer
v1.18.x
Peter Jaszkowiak 7 years ago committed by Barış Soner Uşaklı
parent 15c8693a23
commit dbdc05404d

@ -12,8 +12,7 @@ var questions = {
module.exports = function (config, callback) {
async.waterfall([
function (next) {
process.stdout.write('\n');
winston.info('Now configuring ' + config.database + ' database:');
winston.info('\nNow configuring ' + config.database + ' database:');
getDatabaseConfig(config, next);
},
function (databaseConfig, next) {

@ -5,6 +5,7 @@ var express = require('express');
var bodyParser = require('body-parser');
var fs = require('fs');
var path = require('path');
var childProcess = require('child_process');
var less = require('less');
var async = require('async');
var uglify = require('uglify-js');
@ -127,15 +128,15 @@ function launch(req, res) {
res.json({});
server.close();
var child = require('child_process').spawn('node', ['loader.js'], {
var child = childProcess.spawn('node', ['loader.js'], {
detached: true,
stdio: ['ignore', 'ignore', 'ignore'],
});
process.stdout.write('\nStarting NodeBB\n');
process.stdout.write(' "./nodebb stop" to stop the NodeBB server\n');
process.stdout.write(' "./nodebb log" to view server output\n');
process.stdout.write(' "./nodebb restart" to restart NodeBB\n');
console.log('\nStarting NodeBB');
console.log(' "./nodebb stop" to stop the NodeBB server');
console.log(' "./nodebb log" to view server output');
console.log(' "./nodebb restart" to restart NodeBB');
var filesToDelete = [
'installer.css',

@ -12,15 +12,15 @@ try {
fs.readFileSync(path.join(dirname, 'node_modules/async/package.json'));
} catch (e) {
if (e.code === 'ENOENT') {
process.stdout.write('Dependencies not yet installed.\n');
process.stdout.write('Installing them now...\n\n');
console.warn('Dependencies not yet installed.');
console.log('Installing them now...\n');
packageInstall.updatePackageFile();
packageInstall.preserveExtraneousPlugins();
packageInstall.npmInstallProduction();
require('colors');
process.stdout.write('OK'.green + '\n'.reset);
console.log('OK'.green + '\n'.reset);
} else {
throw e;
}
@ -182,7 +182,7 @@ resetCommand
return options[x];
});
if (!valid) {
process.stdout.write('\n No valid options passed in, so nothing was reset.\n'.red);
console.warn('\n No valid options passed in, so nothing was reset.'.red);
resetCommand.help();
}
@ -206,13 +206,12 @@ program
.option('-s, --schema', 'Update NodeBB data store schema', false)
.option('-b, --build', 'Rebuild assets', false)
.on('--help', function () {
process.stdout.write(
'\n' +
'When running particular upgrade scripts, options are ignored.\n' +
'By default all options are enabled. Passing any options disables that default.\n' +
'Only package and dependency updates: ' + './nodebb upgrade -mi\n'.yellow +
'Only database update: ' + './nodebb upgrade -d\n\n'.yellow
);
console.log('\n' + [
'When running particular upgrade scripts, options are ignored.',
'By default all options are enabled. Passing any options disables that default.',
'Only package and dependency updates: ' + './nodebb upgrade -mi'.yellow,
'Only database update: ' + './nodebb upgrade -d'.yellow,
].join('\n'));
})
.action(function (scripts, options) {
require('./upgrade').upgrade(scripts.length ? scripts : true, options);
@ -229,7 +228,7 @@ program
if (err) {
throw err;
}
process.stdout.write('OK\n'.green);
console.log('OK'.green);
process.exit();
});
});

@ -24,11 +24,11 @@ function buildTargets() {
}).map(function (tuple) {
return ' ' + _.padEnd('"' + tuple[0] + '"', length + 2).magenta + ' | ' + tuple[1];
}).join('\n');
process.stdout.write(
console.log(
'\n\n Build targets:\n' +
('\n ' + _.padEnd('Target', length + 2) + ' | Aliases').green +
'\n ------------------------------------------------------\n'.blue +
output + '\n\n'
output + '\n'
);
}
@ -100,24 +100,23 @@ function listEvents() {
}
function info() {
console.log('');
async.waterfall([
function (next) {
var version = require('../../package.json').version;
process.stdout.write('\n version: ' + version);
console.log(' version: ' + version);
process.stdout.write('\n Node ver: ' + process.version);
console.log(' Node ver: ' + process.version);
next();
},
function (next) {
process.stdout.write('\n git hash: ');
childProcess.execSync('git rev-parse HEAD', {
stdio: 'inherit',
});
var hash = childProcess.execSync('git rev-parse HEAD');
console.log(' git hash: ' + hash);
next();
},
function (next) {
var config = require('../../config.json');
process.stdout.write('\n database: ' + config.database);
console.log(' database: ' + config.database);
next();
},
db.init,
@ -125,8 +124,8 @@ function info() {
db.info(db.client, next);
},
function (info, next) {
process.stdout.write('\n version: ' + info.version);
process.stdout.write('\n engine: ' + info.storageEngine);
console.log(' version: ' + info.version);
console.log(' engine: ' + info.storageEngine);
next();
},
], function (err) {

@ -54,18 +54,19 @@ exports.reset = function (options, callback) {
.map(function (x) { return map[x]; });
if (!tasks.length) {
process.stdout.write('\nNodeBB Reset\n'.bold);
process.stdout.write('No arguments passed in, so nothing was reset.\n\n'.yellow);
process.stdout.write('Use ./nodebb reset ' + '{-t|-p|-w|-s|-a}\n'.red);
process.stdout.write(' -t\tthemes\n');
process.stdout.write(' -p\tplugins\n');
process.stdout.write(' -w\twidgets\n');
process.stdout.write(' -s\tsettings\n');
process.stdout.write(' -a\tall of the above\n');
process.stdout.write('\nPlugin and theme reset flags (-p & -t) can take a single argument\n');
process.stdout.write(' e.g. ./nodebb reset -p nodebb-plugin-mentions, ./nodebb reset -t nodebb-theme-persona\n');
process.stdout.write(' Prefix is optional, e.g. ./nodebb reset -p markdown, ./nodebb reset -t persona\n');
console.log([
'No arguments passed in, so nothing was reset.\n'.yellow,
'Use ./nodebb reset ' + '{-t|-p|-w|-s|-a}'.red,
' -t\tthemes',
' -p\tplugins',
' -w\twidgets',
' -s\tsettings',
' -a\tall of the above',
'',
'Plugin and theme reset flags (-p & -t) can take a single argument',
' e.g. ./nodebb reset -p nodebb-plugin-mentions, ./nodebb reset -t nodebb-theme-persona',
' Prefix is optional, e.g. ./nodebb reset -p markdown, ./nodebb reset -t persona',
].join('\n'));
process.exit(0);
}

@ -38,21 +38,23 @@ function start(options) {
return;
}
if (options.log) {
process.stdout.write('\nStarting NodeBB with logging output\n'.bold);
process.stdout.write('\nHit '.red + 'Ctrl-C '.bold + 'to exit'.red);
process.stdout.write('\nThe NodeBB process will continue to run in the background');
process.stdout.write('\nUse "' + './nodebb stop'.yellow + '" to stop the NodeBB server\n');
process.stdout.write('\n\n'.reset);
console.log('\n' + [
'Starting NodeBB with logging output'.bold,
'Hit '.red + 'Ctrl-C '.bold + 'to exit'.red,
'The NodeBB process will continue to run in the background',
'Use "' + './nodebb stop'.yellow + '" to stop the NodeBB server',
].join('\n'));
} else if (!options.silent) {
process.stdout.write('\nStarting NodeBB\n'.bold);
process.stdout.write(' "' + './nodebb stop'.yellow + '" to stop the NodeBB server\n');
process.stdout.write(' "' + './nodebb log'.yellow + '" to view server output\n');
process.stdout.write(' "' + './nodebb restart'.yellow + '" to restart NodeBB\n\n'.reset);
console.log('\n' + [
'Starting NodeBB'.bold,
' "' + './nodebb stop'.yellow + '" to stop the NodeBB server',
' "' + './nodebb log'.yellow + '" to view server output',
' "' + './nodebb help'.yellow + '" for more commands\n'.reset,
].join('\n'));
}
// Spawn a new NodeBB process
fork(paths.loader, process.argv.slice(3), {
var child = fork(paths.loader, process.argv.slice(3), {
env: process.env,
cwd: dirname,
});
@ -62,15 +64,17 @@ function start(options) {
stdio: 'inherit',
});
}
return child;
}
function stop() {
getRunningPid(function (err, pid) {
if (!err) {
process.kill(pid, 'SIGTERM');
process.stdout.write('Stopping NodeBB. Goodbye!\n');
console.log('Stopping NodeBB. Goodbye!');
} else {
process.stdout.write('NodeBB is already stopped.\n');
console.log('NodeBB is already stopped.');
}
});
}
@ -78,13 +82,13 @@ function stop() {
function restart(options) {
getRunningPid(function (err, pid) {
if (!err) {
process.stdout.write('\nRestarting NodeBB\n'.bold);
console.log('\nRestarting NodeBB'.bold);
process.kill(pid, 'SIGTERM');
options.silent = true;
start(options);
} else {
process.stdout.write('NodeBB could not be restarted, as a running instance could not be found.\n');
console.warn('NodeBB could not be restarted, as a running instance could not be found.');
}
});
}
@ -92,20 +96,21 @@ function restart(options) {
function status() {
getRunningPid(function (err, pid) {
if (!err) {
process.stdout.write('\nNodeBB Running '.bold + '(pid '.cyan + pid.toString().cyan + ')\n'.cyan);
process.stdout.write('\t"' + './nodebb stop'.yellow + '" to stop the NodeBB server\n');
process.stdout.write('\t"' + './nodebb log'.yellow + '" to view server output\n');
process.stdout.write('\t"' + './nodebb restart'.yellow + '" to restart NodeBB\n\n');
console.log('\n' + [
'NodeBB Running '.bold + ('(pid ' + pid.toString() + ')').cyan,
'\t"' + './nodebb stop'.yellow + '" to stop the NodeBB server',
'\t"' + './nodebb log'.yellow + '" to view server output',
'\t"' + './nodebb restart'.yellow + '" to restart NodeBB\n',
].join('\n'));
} else {
process.stdout.write('\nNodeBB is not running\n'.bold);
process.stdout.write('\t"' + './nodebb start'.yellow + '" to launch the NodeBB server\n\n'.reset);
console.log('\nNodeBB is not running'.bold);
console.log('\t"' + './nodebb start'.yellow + '" to launch the NodeBB server\n'.reset);
}
});
}
function log() {
process.stdout.write('\nHit '.red + 'Ctrl-C '.bold + 'to exit'.red);
process.stdout.write('\n\n'.reset);
console.log('\nHit '.red + 'Ctrl-C '.bold + 'to exit\n'.red + '\n'.reset);
childProcess.spawn('tail', ['-F', './logs/output.log'], {
cwd: dirname,
stdio: 'inherit',

@ -12,9 +12,9 @@ function setup() {
winston.info('NodeBB Setup Triggered via Command Line');
process.stdout.write('\nWelcome to NodeBB!\n');
process.stdout.write('\nThis looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.\n');
process.stdout.write('Press enter to accept the default setting (shown in brackets).\n');
console.log('\nWelcome to NodeBB!');
console.log('\nThis looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.');
console.log('Press enter to accept the default setting (shown in brackets).');
async.series([
install.setup,
@ -30,19 +30,19 @@ function setup() {
separator += '=';
}
}
process.stdout.write('\n' + separator + '\n\n');
console.log('\n' + separator + '\n');
if (err) {
winston.error('There was a problem completing NodeBB setup', err);
throw err;
} else {
if (data.hasOwnProperty('password')) {
process.stdout.write('An administrative user was automatically created for you:\n');
process.stdout.write(' Username: ' + data.username + '\n');
process.stdout.write(' Password: ' + data.password + '\n');
process.stdout.write('\n');
console.log('An administrative user was automatically created for you:');
console.log(' Username: ' + data.username + '');
console.log(' Password: ' + data.password + '');
console.log('');
}
process.stdout.write('NodeBB Setup Completed. Run \'./nodebb start\' to manually start your NodeBB server.\n');
console.log('NodeBB Setup Completed. Run "./nodebb start" to manually start your NodeBB server.');
// If I am a child process, notify the parent of the returned data before exiting (useful for notifying
// hosts of auto-generated username/password during headless setups)

@ -105,7 +105,7 @@ function getCurrentVersion(callback) {
function checkPlugins(standalone, callback) {
if (standalone) {
process.stdout.write('Checking installed plugins and themes for updates... ');
console.log('Checking installed plugins and themes for updates... ');
}
async.waterfall([
@ -117,7 +117,7 @@ function checkPlugins(standalone, callback) {
var toCheck = Object.keys(payload.plugins);
if (!toCheck.length) {
process.stdout.write('OK'.green + '\n'.reset);
console.log('OK'.green + ''.reset);
return next(null, []); // no extraneous plugins installed
}
@ -127,10 +127,10 @@ function checkPlugins(standalone, callback) {
json: true,
}, function (err, res, body) {
if (err) {
process.stdout.write('error'.red + '\n'.reset);
console.log('error'.red + ''.reset);
return next(err);
}
process.stdout.write('OK'.green + '\n'.reset);
console.log('OK'.green + ''.reset);
if (!Array.isArray(body) && toCheck.length === 1) {
body = [body];
@ -167,19 +167,19 @@ function upgradePlugins(callback) {
checkPlugins(standalone, function (err, found) {
if (err) {
process.stdout.write('Warning'.yellow + ': An unexpected error occured when attempting to verify plugin upgradability\n'.reset);
console.log('Warning'.yellow + ': An unexpected error occured when attempting to verify plugin upgradability'.reset);
return callback(err);
}
if (found && found.length) {
process.stdout.write('\nA total of ' + String(found.length).bold + ' package(s) can be upgraded:\n');
console.log('\nA total of ' + String(found.length).bold + ' package(s) can be upgraded:');
found.forEach(function (suggestObj) {
process.stdout.write(' * '.yellow + suggestObj.name.reset + ' (' + suggestObj.current.yellow + ' -> '.reset + suggestObj.suggested.green + ')\n'.reset);
console.log(' * '.yellow + suggestObj.name.reset + ' (' + suggestObj.current.yellow + ' -> '.reset + suggestObj.suggested.green + ')\n'.reset);
});
process.stdout.write('\n');
console.log('');
} else {
if (standalone) {
process.stdout.write('\nAll packages up-to-date!'.green + '\n'.reset);
console.log('\nAll packages up-to-date!'.green + ''.reset);
}
return callback();
}
@ -198,7 +198,7 @@ function upgradePlugins(callback) {
}
if (['y', 'Y', 'yes', 'YES'].indexOf(result.upgrade) !== -1) {
process.stdout.write('\nUpgrading packages...');
console.log('\nUpgrading packages...');
var args = ['i'];
found.forEach(function (suggestObj) {
args.push(suggestObj.name + '@' + suggestObj.suggested);
@ -206,7 +206,7 @@ function upgradePlugins(callback) {
cproc.execFile((process.platform === 'win32') ? 'npm.cmd' : 'npm', args, { stdio: 'ignore' }, callback);
} else {
process.stdout.write('\nPackage upgrades skipped'.yellow + '. Check for upgrades at any time by running "'.reset + './nodebb upgrade-plugins'.green + '".\n'.reset);
console.log('Package upgrades skipped'.yellow + '. Check for upgrades at any time by running "'.reset + './nodebb upgrade-plugins'.green + '".'.reset);
callback();
}
});

@ -11,64 +11,60 @@ var meta = require('../meta');
var upgradePlugins = require('./upgrade-plugins').upgradePlugins;
var steps = {
package: function (next) {
process.stdout.write('Updating package.json file with defaults... \n'.yellow);
packageInstall.updatePackageFile();
packageInstall.preserveExtraneousPlugins();
process.stdout.write('OK\n'.green);
next();
package: {
message: 'Updating package.json file with defaults...',
handler: function (next) {
packageInstall.updatePackageFile();
packageInstall.preserveExtraneousPlugins();
next();
},
},
install: function (next) {
process.stdout.write('Bringing base dependencies up to date... \n'.yellow);
packageInstall.npmInstallProduction();
process.stdout.write('OK\n'.green);
next();
install: {
message: 'Bringing base dependencies up to date...',
handler: function (next) {
packageInstall.npmInstallProduction();
next();
},
},
plugins: function (next) {
process.stdout.write('Checking installed plugins for updates... \n'.yellow);
async.series([
db.init,
upgradePlugins,
function (next) {
process.stdout.write('OK\n'.green);
next();
},
], next);
plugins: {
message: 'Checking installed plugins for updates...',
handler: function (next) {
async.series([
db.init,
upgradePlugins,
], next);
},
},
schema: function (next) {
process.stdout.write('Updating NodeBB data store schema...\n'.yellow);
async.series([
db.init,
upgrade.run,
function (next) {
process.stdout.write('OK\n'.green);
next();
},
], next);
schema: {
message: 'Updating NodeBB data store schema...',
handler: function (next) {
async.series([
db.init,
upgrade.run,
], next);
},
},
build: function (next) {
process.stdout.write('Rebuilding assets...\n'.yellow);
async.series([
build.buildAll,
function (next) {
process.stdout.write('OK\n'.green);
next();
},
], next);
build: {
message: 'Rebuilding assets...',
handler: build.buildAll,
},
};
function runSteps(tasks) {
tasks = tasks.map(function (key, i) {
return function (next) {
process.stdout.write(((i + 1) + '. ').bold);
return steps[key](next);
console.log(((i + 1) + '. ').bold + steps[key].message.yellow);
return steps[key].handler(function (err) {
if (err) { return next(err); }
console.log(' OK'.green);
next();
});
};
});
async.series(tasks, function (err) {
if (err) {
process.stdout.write('Error occurred during upgrade');
console.error('Error occurred during upgrade');
throw err;
}
@ -77,14 +73,14 @@ function runSteps(tasks) {
var columns = process.stdout.columns;
var spaces = columns ? new Array(Math.floor(columns / 2) - (message.length / 2) + 1).join(' ') : ' ';
process.stdout.write('\n' + spaces + message.green.bold + '\n\n'.reset);
console.log('\n' + spaces + message.green.bold + '\n'.reset);
process.exit();
});
}
function runUpgrade(upgrades, options) {
process.stdout.write('\nUpdating NodeBB...\n'.cyan);
console.log('\nUpdating NodeBB...'.cyan);
// disable mongo timeouts during upgrade
nconf.set('mongo:options:socketTimeoutMS', 0);

@ -141,7 +141,7 @@ events.deleteAll = function (callback) {
};
events.output = function () {
process.stdout.write('\nDisplaying last ten administrative events...\n'.bold);
console.log('\nDisplaying last ten administrative events...'.bold);
events.getEvents(0, 9, function (err, events) {
if (err) {
winston.error('Error fetching events', err);
@ -149,7 +149,7 @@ events.output = function () {
}
events.forEach(function (event) {
process.stdout.write(' * ' + String(event.timestampISO).green + ' ' + String(event.type).yellow + (event.text ? ' ' + event.text : '') + ' (uid: '.reset + (event.uid ? event.uid : 0) + ')\n');
console.log(' * ' + String(event.timestampISO).green + ' ' + String(event.type).yellow + (event.text ? ' ' + event.text : '') + ' (uid: '.reset + (event.uid ? event.uid : 0) + ')');
});
process.exit(0);

@ -174,7 +174,7 @@ function completeConfigSetup(config, next) {
}
function setupDefaultConfigs(next) {
process.stdout.write('Populating database with default configs, if not already set...\n');
console.log('Populating database with default configs, if not already set...');
var meta = require('./meta');
var defaults = require(path.join(__dirname, '../', 'install/data/defaults.json'));
@ -192,11 +192,11 @@ function enableDefaultTheme(next) {
meta.configs.get('theme:id', function (err, id) {
if (err || id) {
process.stdout.write('Previous theme detected, skipping enabling default theme\n');
console.log('Previous theme detected, skipping enabling default theme');
return next(err);
}
var defaultTheme = nconf.get('defaultTheme') || 'nodebb-theme-persona';
process.stdout.write('Enabling default theme: ' + defaultTheme + '\n');
console.log('Enabling default theme: ' + defaultTheme);
meta.themes.set({
type: 'local',
id: defaultTheme,
@ -211,7 +211,7 @@ function createAdministrator(next) {
return next(err);
}
if (memberCount > 0) {
process.stdout.write('Administrator found, skipping Admin setup\n');
console.log('Administrator found, skipping Admin setup');
next();
} else {
createAdmin(next);
@ -315,7 +315,7 @@ function createAdmin(callback) {
} else {
// If automated setup did not provide a user password, generate one, it will be shown to the user upon setup completion
if (!install.values.hasOwnProperty('admin:password') && !nconf.get('admin:password')) {
process.stdout.write('Password was not provided during automated setup, generating one...\n');
console.log('Password was not provided during automated setup, generating one...');
password = utils.generateUUID().slice(0, 8);
}
@ -365,11 +365,11 @@ function createCategories(next) {
}
if (Array.isArray(categoryData) && categoryData.length) {
process.stdout.write('Categories OK. Found ' + categoryData.length + ' categories.\n');
console.log('Categories OK. Found ' + categoryData.length + ' categories.');
return next();
}
process.stdout.write('No categories found, populating instance with default categories\n');
console.log('No categories found, populating instance with default categories');
fs.readFile(path.join(__dirname, '../', 'install/data/categories.json'), 'utf8', function (err, default_categories) {
if (err) {
@ -416,7 +416,7 @@ function createWelcomePost(next) {
var numTopics = results[1];
if (!parseInt(numTopics, 10)) {
process.stdout.write('Creating welcome post!\n');
console.log('Creating welcome post!');
Topics.post({
uid: 1,
cid: 2,
@ -430,7 +430,7 @@ function createWelcomePost(next) {
}
function enableDefaultPlugins(next) {
process.stdout.write('Enabling default plugins\n');
console.log('Enabling default plugins');
var defaultEnabled = [
'nodebb-plugin-composer-default',
@ -546,7 +546,7 @@ install.save = function (server_conf, callback) {
return callback(err);
}
process.stdout.write('Configuration Saved OK\n');
console.log('Configuration Saved OK');
nconf.file({
file: path.join(__dirname, '..', 'config.json'),

@ -97,12 +97,12 @@ Plugins.reload = function (callback) {
function (next) {
// If some plugins are incompatible, throw the warning here
if (Plugins.versionWarning.length && nconf.get('isPrimary') === 'true') {
process.stdout.write('\n');
console.log('');
winston.warn('[plugins/load] The following plugins may not be compatible with your version of NodeBB. This may cause unintended behaviour or crashing. In the event of an unresponsive NodeBB caused by this plugin, run `./nodebb reset -p PLUGINNAME` to disable it.');
for (var x = 0, numPlugins = Plugins.versionWarning.length; x < numPlugins; x += 1) {
process.stdout.write(' * '.yellow + Plugins.versionWarning[x] + '\n');
console.log(' * '.yellow + Plugins.versionWarning[x]);
}
process.stdout.write('\n');
console.log('');
}
Object.keys(Plugins.loadedHooks).forEach(function (hook) {

@ -91,7 +91,7 @@ Upgrade.check = function (callback) {
};
Upgrade.run = function (callback) {
process.stdout.write('\nParsing upgrade scripts... ');
console.log('\nParsing upgrade scripts... ');
var queue = [];
var skipped = 0;
@ -120,7 +120,7 @@ Upgrade.run = function (callback) {
};
Upgrade.runParticular = function (names, callback) {
process.stdout.write('\nParsing upgrade scripts... ');
console.log('\nParsing upgrade scripts... ');
async.waterfall([
async.apply(file.walk, path.join(__dirname, './upgrades')),
@ -135,7 +135,7 @@ Upgrade.runParticular = function (names, callback) {
};
Upgrade.process = function (files, skipCount, callback) {
process.stdout.write('OK'.green + ' | '.reset + String(files.length).cyan + ' script(s) found'.cyan + (skipCount > 0 ? ', '.cyan + String(skipCount).cyan + ' skipped'.cyan : '') + '\n'.reset);
console.log('OK'.green + ' | '.reset + String(files.length).cyan + ' script(s) found'.cyan + (skipCount > 0 ? ', '.cyan + String(skipCount).cyan + ' skipped'.cyan : ''));
async.waterfall([
function (next) {
@ -157,14 +157,14 @@ Upgrade.process = function (files, skipCount, callback) {
date: date,
};
process.stdout.write(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '...\n');
console.log(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '...');
// For backwards compatibility, cross-reference with schemaDate (if found). If a script's date is older, skip it
if ((!results.schemaDate && !results.schemaLogCount) || (scriptExport.timestamp <= results.schemaDate && semver.lt(version, '1.5.0'))) {
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
readline.moveCursor(process.stdout, 0, -1);
process.stdout.write(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '... ' + 'skipped\n'.grey);
console.log(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '... ' + 'skipped'.grey);
db.sortedSetAdd('schemaLog', Date.now(), path.basename(file, '.js'), next);
return;
}
@ -174,14 +174,14 @@ Upgrade.process = function (files, skipCount, callback) {
progress: progress,
})(function (err) {
if (err) {
process.stdout.write('error\n'.red);
console.error('Error occurred');
return next(err);
}
readline.clearLine(process.stdout, 0);
readline.cursorTo(process.stdout, 0);
readline.moveCursor(process.stdout, 0, -1);
process.stdout.write(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '... ' + 'OK\n'.green);
console.log(' → '.white + String('[' + [date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate()].join('/') + '] ').gray + String(scriptExport.name).reset + '... ' + 'OK'.green);
// Record success in schemaLog
db.sortedSetAdd('schemaLog', Date.now(), path.basename(file, '.js'), next);
@ -189,7 +189,7 @@ Upgrade.process = function (files, skipCount, callback) {
}, next);
},
function (next) {
process.stdout.write('Upgrade complete!\n\n'.green);
console.log('Upgrade complete!\n'.green);
setImmediate(next);
},
], callback);

Loading…
Cancel
Save