Skip to content

Commit 837f6fa

Browse files
committed
fix(setup): fix start/no-start option
closes #615 - respect no-start in local installs - fix ui.confirm usage
1 parent 6ccf6be commit 837f6fa

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/commands/setup.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class SetupCommand extends Command {
5858
argv.dbpath = path.join(process.cwd(), 'content/data/ghost-local.db');
5959
}
6060

61-
argv.start = true;
61+
argv.start = (typeof argv.start === 'undefined') ? true : argv.start;
6262

6363
// In the case that the user runs `ghost setup --local`, we want to make
6464
// sure we're set up in development mode
@@ -184,7 +184,7 @@ class SetupCommand extends Command {
184184
// (or --no-prompt was provided, and we already defaulted to true)
185185
// In this case, we don't prompt, we use the value of argv.start
186186
if (argv.start || argv.start === false) {
187-
return Promise.resolve({yes: argv.start});
187+
return Promise.resolve(argv.start);
188188
}
189189

190190
return this.ui.confirm('Do you want to start Ghost?', true);

test/unit/commands/setup-spec.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ describe('Unit: Commands > Setup', function () {
101101
} catch (error) {
102102
expect(error.message).to.equal('Take a break');
103103
expect(argVSpy).to.deep.equal(argvB);
104+
argVSpy = {local: true, start: false};
105+
}
106+
107+
try {
108+
setup.run(argVSpy);
109+
expect(false, 'An error should have been thrown').to.be.true;
110+
} catch (error) {
111+
expect(error.message).to.equal('Take a break');
112+
expect(argVSpy).to.deep.equal(Object.assign(argvB, {start: false}));
104113
}
105114
});
106115

@@ -452,7 +461,7 @@ describe('Unit: Commands > Setup', function () {
452461
const system = {hook: () => Promise.resolve()};
453462
const setup = new SetupCommand(ui, system);
454463
let tasks;
455-
setup.runCommand = () => Promise.resolve();
464+
const runCommand = sinon.stub(setup, 'runCommand').resolves();
456465

457466
setup.addStage('zest', () => true, null, 'Zesty');
458467
setup.addStage('test', () => true, null, 'Test');
@@ -470,6 +479,7 @@ describe('Unit: Commands > Setup', function () {
470479
expect(ui.confirm.calledTwice).to.be.true;
471480
expect(ui.confirm.args[0][0]).to.match(/Zesty/);
472481
expect(ui.confirm.args[1][0]).to.match(/Test/);
482+
expect(runCommand.calledOnce).to.be.true;
473483
});
474484
});
475485
});

0 commit comments

Comments
 (0)