Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): improve error message when node or cli version is incompatible #1574

Merged
merged 1 commit into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/tasks/yarn-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,16 @@ const subTasks = {
const isPrerelease = Boolean(prerelease(cliPackage.version));

if (!skipNodeVersionCheck && engines.node && !satisfies(process.versions.node, engines.node)) {
throw new SystemError(`Ghost v${ctx.version} is not compatible with the current Node version.`);
throw new SystemError(
`Ghost v${ctx.version} is not compatible with the current Node version.` +
` Your node version is ${process.versions.node}, but Ghost v${ctx.version} requires ${engines.node}`
);
}

if (engines.cli && !isPrerelease && !satisfies(cliPackage.version, engines.cli)) {
throw new SystemError({
message: `Ghost v${ctx.version} is not compatible with this version of the CLI.`,
message: `Ghost v${ctx.version} is not compatible with this version of the CLI.` +
` Your CLI version is ${cliPackage.version}, but Ghost v${ctx.version} requires ${engines.cli}`,
help: `Run ${chalk.cyan('`npm install -g ghost-cli@latest`')} to upgrade the CLI, then try again.`
});
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit/tasks/yarn-install-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ describe('Unit: Tasks > yarn-install', function () {
expect(false, 'error should have been thrown').to.be.true;
}).catch((error) => {
expect(error).to.be.an.instanceof(errors.SystemError);
expect(error.message).to.equal('Ghost v1.5.0 is not compatible with the current Node version.');
expect(error.message).to.equal(`Ghost v1.5.0 is not compatible with the current Node version. Your node version is ${process.versions.node}, but Ghost v1.5.0 requires ^0.10.0`);
expect(infoStub.calledOnce).to.be.true;
expect(infoStub.calledWithExactly('ghost', {version: '1.5.0', agent: false})).to.be.true;
});
Expand Down Expand Up @@ -216,7 +216,7 @@ describe('Unit: Tasks > yarn-install', function () {
expect(false, 'error should have been thrown').to.be.true;
}).catch((error) => {
expect(error).to.be.an.instanceof(errors.SystemError);
expect(error.message).to.equal('Ghost v1.5.0 is not compatible with this version of the CLI.');
expect(error.message).to.equal(`Ghost v1.5.0 is not compatible with this version of the CLI. Your CLI version is 1.0.0, but Ghost v1.5.0 requires ^0.0.1`);
expect(infoStub.calledOnce).to.be.true;
expect(infoStub.calledWithExactly('ghost', {version: '1.5.0', agent: false})).to.be.true;
});
Expand Down