diff --git a/lib/commands/setup.js b/lib/commands/setup.js index fe77ef58f..d9a8185c8 100644 --- a/lib/commands/setup.js +++ b/lib/commands/setup.js @@ -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 @@ -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); diff --git a/test/unit/commands/setup-spec.js b/test/unit/commands/setup-spec.js index 1943e4394..a3eeb7e6f 100644 --- a/test/unit/commands/setup-spec.js +++ b/test/unit/commands/setup-spec.js @@ -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})); } }); @@ -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'); @@ -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; }); }); });