Skip to content

Commit

Permalink
feat(install): improved local install ux
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine committed Nov 8, 2019
1 parent 5b65481 commit 9494d51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/commands/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class InstallCommand extends Command {

// If command is `ghost install local`, or command is
// `ghost install 1.x.x --local`, do a local install
if (version === 'local' || argv.local) {
if (version === 'local' || argv.local || (argv._ && argv._.includes('local'))) {
local = true;
version = (version === 'local') ? null : version;
this.system.setEnvironment(true, true);
Expand Down
28 changes: 28 additions & 0 deletions test/unit/commands/install-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,34 @@ describe('Unit: Commands > Install', function () {
});
});

it('runs local install when command is `ghost install <version> local`', function () {
const dirEmptyStub = sinon.stub().returns(true);
const listrStub = sinon.stub();
listrStub.onFirstCall().resolves();
listrStub.onSecondCall().rejects();
const setEnvironmentStub = sinon.stub();

const InstallCommand = proxyquire(modulePath, {
'../utils/dir-is-empty': dirEmptyStub
});
const testInstance = new InstallCommand({listr: listrStub}, {cliVersion: '1.0.0', setEnvironment: setEnvironmentStub});
const runCommandStub = sinon.stub(testInstance, 'runCommand').resolves();

return testInstance.run({version: '1.5.0', zip: '', v1: false, _: ['install', 'local']}).then(() => {
expect(false, 'run should have rejected').to.be.true;
}).catch(() => {
expect(dirEmptyStub.calledOnce).to.be.true;
expect(runCommandStub.calledOnce).to.be.true;
expect(listrStub.calledOnce).to.be.true;
expect(listrStub.args[0][1]).to.deep.equal({
argv: {version: '1.5.0', zip: '', v1: false, _: ['install', 'local']},
cliVersion: '1.0.0'
});
expect(setEnvironmentStub.calledOnce).to.be.true;
expect(setEnvironmentStub.calledWithExactly(true, true)).to.be.true;
});
});

it('handles case with custom version and export file', function () {
const dirEmptyStub = sinon.stub().returns(true);
const yarnInstallStub = sinon.stub().resolves();
Expand Down

0 comments on commit 9494d51

Please sign in to comment.