Skip to content

Commit

Permalink
Updating enable logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ErisDS committed Jul 10, 2017
1 parent aad7c3c commit cfec3e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
6 changes: 3 additions & 3 deletions lib/commands/setup.js
Expand Up @@ -142,6 +142,7 @@ class SetupCommand extends Command {
// Tack on db migration task to the end
tasks.push({
title: 'Running database migrations',
skip: (ctx) => !ctx.argv.migrate,
task: migrate
});
}
Expand All @@ -156,7 +157,6 @@ class SetupCommand extends Command {
// (or --no-prompt was provided, and we already defaulted to true)
// In this case, we don't prompt, we use the value of argv.start
if (argv.start) {
console.log('argv.start', argv.start);
return Promise.resolve({yes: argv.start});
}

Expand All @@ -169,10 +169,10 @@ class SetupCommand extends Command {
}

SetupCommand.description = 'Setup an installation of Ghost (after it is installed)';
SetupCommand.params = '[stages..]';
SetupweeeCommand.params = '[stages..]';
SetupCommand.options = {
start: {
description: '[--no-start] Automatically start Ghost',
description: '[--no-start] Enable/disable automatically starting Ghost',
type: 'boolean'
},
local: {
Expand Down
28 changes: 7 additions & 21 deletions lib/commands/start.js
Expand Up @@ -35,33 +35,18 @@ class StartCommand extends Command {
instance.running = this.system.environment;
});

// @TODO --quiet will make enable never happen!
if (argv.quiet) {
return start();
}

return this.ui.run(start, 'Starting Ghost').then(() => {
// If process manager doesn't support enable behavior OR
// it's already enabled, then skip prompt
// If process manager doesn't support enable behavior OR it's already enabled, don't try to enable
if (!ProcessManager.supportsEnableBehavior(processInstance) || processInstance.isEnabled()) {
return Promise.resolve({yes: false});
argv.enable = false;
}

// If we are not allowed to prompt, set the default value, which should be true
if (!argv.prompt) {
argv.enable = true;
}

// If argv.enable has a value, this means either --enable or --no-enable were explicitly provided
// (or --no-prompt was provided, and we already defaulted to true)
// In this case, we don't prompt, we use the value of argv.enable
if (argv.enable) {
console.log('enable', argv.enable);
return Promise.resolve({yes: argv.enable});
}

return this.ui.confirm('Do you wish to enable the Ghost instance to start on reboot?')
}).then((answer) => {
if (!answer.yes) {
if (!argv.enable) {
return Promise.resolve();
}

Expand All @@ -81,8 +66,9 @@ class StartCommand extends Command {
StartCommand.description = 'Start an instance of Ghost';
StartCommand.options = {
enable: {
description: 'Enable the instance to restart on server reboot (if the process manager supports it)',
type: 'boolean'
description: '[--no-enable] Enable/don\'t enable the instance to restart on server reboot (if the process manager supports it)',
type: 'boolean',
default: true
}
};

Expand Down

0 comments on commit cfec3e5

Please sign in to comment.