From 0db98998078ce7979314fae61eaa84f3183418f9 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Mon, 26 Sep 2016 14:28:53 -0500 Subject: [PATCH] :bug: ensure `ghost update` starts the new version in the same environment as the old version --- lib/commands/update.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/commands/update.js b/lib/commands/update.js index 52ac4970d..ffc857e76 100644 --- a/lib/commands/update.js +++ b/lib/commands/update.js @@ -23,7 +23,7 @@ module.exports = BaseCommand.extend({ findVersion = require('../utils/version'), config = Config.load('.ghost-cli'), self = this, - installPath; + installPath, environment; if (options.rollback) { if (!config.get('previous-version')) { @@ -34,6 +34,8 @@ module.exports = BaseCommand.extend({ installPath = path.join(process.cwd(), 'versions', version); } + environment = config.get('running', null); + return this.runCommand('doctor', 'update').then(function resolveVersion() { if (options.rollback) { return Promise.resolve(); @@ -51,6 +53,12 @@ module.exports = BaseCommand.extend({ }, 'Downloading the updated version of Ghost'); }); }).then(function stopCurrentGhost() { + if (!environment) { + // If environment isn't set ghost is not running. + // Therefore we don't need to stop Ghost, so skip that part + return Promise.resolve(); + } + return self.runCommand('stop'); }).then(function afterStop() { var fs = require('fs-extra'), @@ -65,7 +73,10 @@ module.exports = BaseCommand.extend({ (options.rollback) ? null : config.get('active-version') ).set('active-version', version).save(); - return self.runCommand('start'); + var startConfig = []; + startConfig[environment] = true; + + return self.runCommand('start', startConfig); }); } });