Skip to content

Commit

Permalink
ghost install local command shortcut
Browse files Browse the repository at this point in the history
- ghost install local will install the latest version but bypass many of the fancier config options. this is useful for theme developers who just want to get a quick install of ghost running
  • Loading branch information
acburdine committed Sep 26, 2016
1 parent e6727eb commit 0d9efe2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module.exports = BaseCommand.extend({
findVersion = require('../utils/version'),
Config = require('../utils/config'),
self = this,
installPath, dir, blogUrl;
local = false,
installPath, dir;

// Dir was specified, so we make sure it exists and chdir into it.
if (options.dir) {
Expand All @@ -42,6 +43,11 @@ module.exports = BaseCommand.extend({
return Promise.reject('Current directory is not empty, Ghost cannot be installed here.');
}

if (version === 'local') {
local = true;
version = null;
}

return findVersion(version).then(function runDoctor(resolvedVersion) {
version = resolvedVersion;
installPath = path.join(process.cwd(), 'versions', version);
Expand Down Expand Up @@ -75,9 +81,17 @@ module.exports = BaseCommand.extend({
cliConfig.set('cli-version', options.parent._version)
.set('active-version', version).save();

// If 'local' is specified we don't need to run the config command
if (local) {
return Promise.resolve();
}

return self.runCommand('config', null, null, {return: true});
}).then(function ask(config) {
blogUrl = config.url;
}).then(function ask() {
// If 'local' is specified we will automatically start ghost
if (local) {
return Promise.resolve({start: true});
}

return self.ui.prompt({
type: 'confirm',
Expand All @@ -90,7 +104,7 @@ module.exports = BaseCommand.extend({
return Promise.resolve();
}

return self.runCommand('start', require('url').parse(blogUrl).hostname);
return self.runCommand('start', {development: local});
});
}
});

0 comments on commit 0d9efe2

Please sign in to comment.