Skip to content

Commit 9906ab6

Browse files
committed
fix(compat-check): handle cli prerelease case
1 parent 75283e3 commit 9906ab6

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lib/tasks/yarn-install.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const subTasks = {
3131
return Promise.reject(new errors.SystemError(`Ghost v${ctx.version} is not compatible with the current Node version.`));
3232
}
3333

34-
if (data.engines && data.engines.cli && !semver.satisfies(cliPackage.version, data.engines.cli)) {
34+
if (data.engines && data.engines.cli && !semver.prerelease(cliPackage.version) && !semver.satisfies(cliPackage.version, data.engines.cli)) {
3535
return Promise.reject(new errors.SystemError(`Ghost v${ctx.version} is not compatible with this version of the CLI.`));
3636
}
3737

test/unit/tasks/yarn-install-spec.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ describe('Unit: Tasks > yarn-install', function () {
195195
};
196196
const yarnStub = sinon.stub().resolves({stdout: JSON.stringify(data)});
197197
const dist = proxyquire(modulePath, {
198-
'../utils/yarn': yarnStub
198+
'../utils/yarn': yarnStub,
199+
'../../package.json': {version: '1.0.0'}
199200
}).subTasks.dist;
200201
const ctx = {version: '1.5.0'};
201202

@@ -209,6 +210,31 @@ describe('Unit: Tasks > yarn-install', function () {
209210
});
210211
});
211212

213+
it('resolves if Ghost version isn\'t compatible with CLI version, but CLI is a prerelease version', function () {
214+
const data = {
215+
data: {
216+
engines: {node: process.versions.node, cli: '^1.9.0'},
217+
dist: {shasum: 'asdf1234', tarball: 'something.tgz'}
218+
}
219+
};
220+
const yarnStub = sinon.stub().resolves({stdout: JSON.stringify(data)});
221+
const dist = proxyquire(modulePath, {
222+
'../utils/yarn': yarnStub,
223+
'../../package.json': {version: '1.10.0-beta.0'}
224+
}).subTasks.dist;
225+
const ctx = {version: '1.5.0'};
226+
227+
return dist(ctx).then(() => {
228+
expect(yarnStub.calledOnce).to.be.true;
229+
expect(yarnStub.calledWithExactly(['info', '[email protected]', '--json'])).to.be.true;
230+
expect(ctx).to.deep.equal({
231+
version: '1.5.0',
232+
shasum: 'asdf1234',
233+
tarball: 'something.tgz'
234+
});
235+
});
236+
});
237+
212238
it('adds shasum and tarball values to context', function () {
213239
const data = {data: {dist: {shasum: 'asdf1234', tarball: 'something.tgz'}}};
214240
const yarnStub = sinon.stub().resolves({stdout: JSON.stringify(data)});

0 commit comments

Comments
 (0)