Skip to content

Commit c7875c9

Browse files
committed
fix(ux): add warning when custom version and --zip are passed
1 parent 46f4da5 commit c7875c9

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lib/commands/install.js

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ class InstallCommand extends Command {
9797
const {resolveVersion, versionFromZip} = require('../utils/version');
9898
const {version, zip, v1} = ctx.argv;
9999

100+
if (version && zip) {
101+
ctx.ui.log('Warning: you specified both a specific version and a zip file. The version in the zip file will be used.', 'yellow');
102+
}
103+
100104
let resolvedVersion = null;
101105
if (zip) {
102106
resolvedVersion = await versionFromZip(zip);

test/unit/commands/install-spec.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -308,16 +308,38 @@ describe('Unit: Commands > Install', function () {
308308
const InstallCommand = proxyquire(modulePath, {
309309
'../utils/version': {resolveVersion, versionFromZip}
310310
});
311+
const log = sinon.stub();
312+
313+
const testInstance = new InstallCommand({}, {});
314+
const context = {argv: {zip: '/some/zip/file.zip'}, ui: {log}};
315+
316+
await testInstance.version(context);
317+
expect(resolveVersion.called).to.be.false;
318+
expect(versionFromZip.calledOnce).to.be.true;
319+
expect(versionFromZip.calledWith('/some/zip/file.zip')).to.be.true;
320+
expect(context.version).to.equal('1.5.2');
321+
expect(context.installPath).to.equal(path.join(process.cwd(), 'versions/1.5.2'));
322+
expect(log.called).to.be.false;
323+
});
324+
325+
it('logs if both version and zip are passed', async function () {
326+
const resolveVersion = sinon.stub().resolves('1.5.0');
327+
const versionFromZip = sinon.stub().resolves('1.5.2');
328+
const InstallCommand = proxyquire(modulePath, {
329+
'../utils/version': {resolveVersion, versionFromZip}
330+
});
331+
const log = sinon.stub();
311332

312333
const testInstance = new InstallCommand({}, {});
313-
const context = {argv: {version: '1.0.0', zip: '/some/zip/file.zip'}};
334+
const context = {argv: {version: '1.0.0', zip: '/some/zip/file.zip'}, ui: {log}};
314335

315336
await testInstance.version(context);
316337
expect(resolveVersion.called).to.be.false;
317338
expect(versionFromZip.calledOnce).to.be.true;
318339
expect(versionFromZip.calledWith('/some/zip/file.zip')).to.be.true;
319340
expect(context.version).to.equal('1.5.2');
320341
expect(context.installPath).to.equal(path.join(process.cwd(), 'versions/1.5.2'));
342+
expect(log.calledOnce).to.be.true;
321343
});
322344
});
323345

0 commit comments

Comments
 (0)