Skip to content

Commit d0ff7fe

Browse files
ErisDSacburdine
authored andcommitted
fix(ui): 🎨 fixup start & enable flag logic
refs #313 - the `ghost setup --start` flag - The default value for "start" is "prompt" - The fallback default value for "start", if it's not allowed to prompt is true - Passing --no-start will set start to false, and not prompt - Passing --start will set start to true, and not prompt - the `ghost start --enable` flag - Enabling doesn't trigger any prompt - The default value for "enable" is true - Passing --enable doesn't change anything - Passing --no-enable prevents enabling - calling `ghost uninstall` will now call `ghost stop --disable`
1 parent 1b7bf97 commit d0ff7fe

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

‎lib/commands/setup.js

+11-4
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,15 @@ class SetupCommand extends Command {
147147
}
148148

149149
return this.ui.listr(tasks, {setup: true}).then(() => {
150-
if (!argv.prompt || argv.start) {
150+
// If we are not allowed to prompt, set the default value, which should be true
151+
if (!argv.prompt) {
152+
argv.start = true;
153+
}
154+
155+
// If argv.start has a value, this means either --start or --no-start were explicitly provided
156+
// (or --no-prompt was provided, and we already defaulted to true)
157+
// In this case, we don't prompt, we use the value of argv.start
158+
if (argv.start || argv.start === false) {
151159
return Promise.resolve({yes: argv.start});
152160
}
153161

@@ -163,9 +171,8 @@ SetupCommand.description = 'Setup an installation of Ghost (after it is installe
163171
SetupCommand.params = '[stages..]';
164172
SetupCommand.options = {
165173
start: {
166-
description: 'Automatically start Ghost without prompting',
167-
type: 'boolean',
168-
default: false
174+
description: '[--no-start] Enable/disable automatically starting Ghost',
175+
type: 'boolean'
169176
},
170177
local: {
171178
alias: 'l',

‎lib/commands/start.js

+7-14
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,18 @@ class StartCommand extends Command {
3535
instance.running = this.system.environment;
3636
});
3737

38+
// @TODO --quiet will make enable never happen!
3839
if (argv.quiet) {
3940
return start();
4041
}
4142

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

49-
// If prompts are disabled or enable is passed,
50-
// skip prompt
51-
if (argv.enable || !argv.prompt) {
52-
return Promise.resolve({yes: argv.enable});
53-
}
54-
55-
return this.ui.confirm('Do you wish to enable the Ghost instance to start on reboot?')
56-
}).then((answer) => {
57-
if (!answer.yes) {
49+
if (!argv.enable) {
5850
return Promise.resolve();
5951
}
6052

@@ -74,8 +66,9 @@ class StartCommand extends Command {
7466
StartCommand.description = 'Start an instance of Ghost';
7567
StartCommand.options = {
7668
enable: {
77-
description: 'Enable the instance to restart on server reboot (if the process manager supports it)',
78-
type: 'boolean'
69+
description: '[--no-enable] Enable/don\'t enable the instance to restart on server reboot (if the process manager supports it)',
70+
type: 'boolean',
71+
default: true
7972
}
8073
};
8174

‎lib/commands/uninstall.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class UninstallCommand extends Command {
3333
skip: () => !instance.running,
3434
task: () => {
3535
instance.loadRunningEnvironment(true);
36-
// If the instance is currently running we need to make
37-
// sure it gets stopped
38-
return this.runCommand(StopCommand, {quiet: true});
36+
// If the instance is currently running we need to make sure
37+
// it gets stopped and disabled if possible
38+
return this.runCommand(StopCommand, {disable: true});
3939
}
4040
}, {
4141
title: 'Removing related configuration',

0 commit comments

Comments
 (0)