Skip to content

Commit

Permalink
✨ make ghost run wait for Ghost to finish starting
Browse files Browse the repository at this point in the history
closes #66,#61
- breaking: won't work with any ghost versions < 1.0.0-alpha.8
  • Loading branch information
acburdine committed Nov 7, 2016
1 parent ab72ec3 commit c9a4aaf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
25 changes: 16 additions & 9 deletions lib/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,26 @@ module.exports.Command = BaseCommand.extend({
process.exit(1);
});

// TODO: once Ghost itself supports sending messages to parent
// process upon successful startup, change this to wait for Ghost
// to send a message
if (process.send) {
process.send({started: true});
}
self.child.on('message', function (message) {
console.log(message);
if (message.started) {
self.sendMessage(message);
return;
}

self.sendMessage({started: false, error: message.error});
});
}).catch(function (error) {
if (process.send) {
process.send({error: true, message: error.message});
}
this.sendMessage({started: false, error: error.message});
});
},

sendMessage: function sendMessage(message) {
if (process.send) {
process.send(message);
}
},

exit: function exit() {
if (this.child) {
this.child.kill();
Expand Down
2 changes: 1 addition & 1 deletion lib/process/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = BaseProcess.extend({
if (msg.error) {
fs.unlinkSync(path.join(cwd, PID_FILE));

reject(msg.message);
reject(msg.error);
}

if (msg.started) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/resolve-version.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var semver = require('semver'),
Promise = require('bluebird'),
npm = require('./npm'),
MIN_RELEASE = '>= 1.0.0-alpha.5';
MIN_RELEASE = '>= 1.0.0-alpha.8';

module.exports = function resolveVersion(version, update) {
if (version && !semver.satisfies(version, MIN_RELEASE)) {
Expand Down

0 comments on commit c9a4aaf

Please sign in to comment.