Skip to content

Commit

Permalink
🐛 ensure ghost update starts the new version in the same environmen…
Browse files Browse the repository at this point in the history
…t as the old version
  • Loading branch information
acburdine committed Sep 26, 2016
1 parent 9c337f9 commit 0db9899
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/commands/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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();
Expand All @@ -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'),
Expand All @@ -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);
});
}
});

0 comments on commit 0db9899

Please sign in to comment.