Skip to content

Commit

Permalink
fix(setup): fix start/no-start option
Browse files Browse the repository at this point in the history
closes #615
- respect no-start in local installs
- fix ui.confirm usage
  • Loading branch information
acburdine committed Mar 26, 2018
1 parent 6ccf6be commit 46d64f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/commands/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SetupCommand extends Command {
argv.dbpath = path.join(process.cwd(), 'content/data/ghost-local.db');
}

argv.start = true;
argv.start = (typeof argv.start === 'undefined') ? true : argv.start;

// In the case that the user runs `ghost setup --local`, we want to make
// sure we're set up in development mode
Expand Down Expand Up @@ -184,7 +184,7 @@ 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 || argv.start === false) {
return Promise.resolve({yes: argv.start});
return Promise.resolve(argv.start);
}

return this.ui.confirm('Do you want to start Ghost?', true);
Expand Down
12 changes: 11 additions & 1 deletion test/unit/commands/setup-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ describe('Unit: Commands > Setup', function () {
} catch (error) {
expect(error.message).to.equal('Take a break');
expect(argVSpy).to.deep.equal(argvB);
argVSpy = {local: true, start: false};
}

try {
setup.run(argVSpy);
expect(false, 'An error should have been thrown').to.be.true;
} catch (error) {
expect(error.message).to.equal('Take a break');
expect(argVSpy).to.deep.equal(Object.assign(argvB, {start: false}));
}
});

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

setup.addStage('zest', () => true, null, 'Zesty');
setup.addStage('test', () => true, null, 'Test');
Expand All @@ -470,6 +479,7 @@ describe('Unit: Commands > Setup', function () {
expect(ui.confirm.calledTwice).to.be.true;
expect(ui.confirm.args[0][0]).to.match(/Zesty/);
expect(ui.confirm.args[1][0]).to.match(/Test/);
expect(runCommand.calledOnce).to.be.true;
});
});
});
Expand Down

0 comments on commit 46d64f8

Please sign in to comment.