From 1bd60167ba620fde8929018c1e7fa09ab1956956 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Tue, 20 Sep 2016 11:43:43 -0500 Subject: [PATCH] :bug: pass environment to process manager and set contentPath on start --- lib/commands/start.js | 21 +++++++++++++-------- lib/process/local.js | 6 ++++-- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/commands/start.js b/lib/commands/start.js index 20c3916b7..ab702505c 100644 --- a/lib/commands/start.js +++ b/lib/commands/start.js @@ -26,11 +26,12 @@ module.exports = BaseCommand.extend({ var resolveProcessManager = require('../process').resolve, Config = require('../utils/config'), Promise = require('bluebird'), - env = {}, + path = require('path'), + self = this, environment, config, pm, cliConfig; options = options || {}; - env.NODE_ENV = environment = (options.production || !options.development) ? 'production' : 'development'; + environment = (options.production || !options.development) ? 'production' : 'development'; config = new Config('config.' + environment + '.json'); cliConfig = new Config('.ghost-cli'); @@ -41,11 +42,15 @@ module.exports = BaseCommand.extend({ pm = resolveProcessManager(config); - return this.ui.run( - Promise.resolve(pm.start(process.cwd())), - 'Starting Ghost instance' - ).then(function () { - cliConfig.set('running', environment).save(); - }); + // TODO: rethink this + return this.runCommand('config', 'paths.contentPath', path.join(process.cwd(), 'content'), {}) + .then(function () { + return self.ui.run( + Promise.resolve(pm.start(process.cwd(), environment)), + 'Starting Ghost instance' + ); + }).then(function () { + cliConfig.set('running', environment).save(); + }); } }); diff --git a/lib/process/local.js b/lib/process/local.js index a45ccf259..3d20d4667 100644 --- a/lib/process/local.js +++ b/lib/process/local.js @@ -6,16 +6,18 @@ PID_FILE = '.ghostpid'; module.exports = BaseProcess.extend({ name: 'local', - start: function start(cwd) { + start: function start(cwd, environment) { var fs = require('fs'), path = require('path'), + assign = require('lodash/assign'), spawn = require('child_process').spawn, cp; cp = spawn('node', ['current/index.js'], { cwd: cwd, detached: true, - stdio: 'ignore' + stdio: 'ignore', + env: assign({NODE_ENV: environment}, process.env) }); fs.writeFileSync(path.join(cwd, PID_FILE), cp.pid);