Skip to content

Commit

Permalink
🎨 various fixes for ghost install local
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine committed Nov 8, 2016
1 parent 1b49eaa commit a716d84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 4 additions & 6 deletions lib/commands/run.js
Expand Up @@ -20,12 +20,14 @@ module.exports.Command = BaseCommand.extend({
'production' : 'development';

var KnexMigrator = require('knex-migrator'),
merge = require('lodash/merge'),
spawn = require('child_process').spawn,
path = require('path'),
self = this,
knexMigrator;

// knex-migrator needs to know the content path
process.env.paths__contentPath = path.join(process.cwd(), 'content');

knexMigrator = new KnexMigrator({
knexMigratorFilePath: path.join(process.cwd(), 'current')
});
Expand All @@ -42,10 +44,7 @@ module.exports.Command = BaseCommand.extend({
}).then(function () {
self.child = spawn(process.execPath, ['current/index.js'], {
cwd: process.cwd(),
stdio: [0, 1, 2, 'ipc'],
env: merge({
paths__contentPath: path.join(process.cwd(), 'content')
}, process.env)
stdio: [0, 1, 2, 'ipc']
});

self.child.on('error', function (error) {
Expand All @@ -54,7 +53,6 @@ module.exports.Command = BaseCommand.extend({
});

self.child.on('message', function (message) {
console.log(message);
if (message.started) {
self.sendMessage(message);
return;
Expand Down
13 changes: 9 additions & 4 deletions lib/commands/setup.js
Expand Up @@ -18,15 +18,20 @@ module.exports.Command = BaseCommand.extend({
this.checkValidInstall();

var local = options.local || false,
self = this,
Promise = require('bluebird'),
config;
path = require('path'),
self = this;

delete options.local;

config = (local) ? Promise.resolve() : this.runCommand('config', null, null, options);
if (local) {
options.url = 'http://localhost:2368/',
options.db = 'sqlite3',
options.dbpath = path.join(process.cwd(), 'content/data/ghost-local.db');
options.environment = 'development';
}

return config.then(function afterConfig() {
return this.runCommand('config', null, null, options).then(function afterConfig() {
// If 'local' is specified we will automatically start ghost
if (local) {
return Promise.resolve({start: true});
Expand Down
1 change: 0 additions & 1 deletion lib/commands/start.js
Expand Up @@ -40,7 +40,6 @@ module.exports.Command = BaseCommand.extend({

pm = resolveProcessManager(config);

// TODO: rethink this
return self.ui.run(
Promise.resolve(pm.start(process.cwd(), environment)),
'Starting Ghost instance'
Expand Down

0 comments on commit a716d84

Please sign in to comment.