Skip to content

Commit

Permalink
chore(utils): improve error message for incompatible ghost zip (#702)
Browse files Browse the repository at this point in the history
refs #681
refs #587

Give the user more information why the installation of the zip file failed. Renders the required and the current installed CLI version and the command to run to solve the issue.
  • Loading branch information
aileen authored and kirrg001 committed Apr 11, 2018
1 parent 981da23 commit 3a77ec8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/utils/version-from-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ module.exports = function versionFromZip(zipPath, currentVersion) {
}

if (pkg.engines && pkg.engines.cli && !semver.satisfies(cliPackage.version, pkg.engines.cli)) {
return Promise.reject(new errors.SystemError('Zip file contains a Ghost version incompatible with this version of the CLI.'));
return Promise.reject(new errors.SystemError({
message: 'Zip file contains a Ghost version incompatible with this version of the CLI.',
help: `Required: v${pkg.engines.cli}, current: v${cliPackage.version}`,
suggestion: 'npm install -g ghost-cli@latest'
}));
}

if (currentVersion && semver.lt(pkg.version, currentVersion)) {
Expand Down
2 changes: 2 additions & 0 deletions test/unit/utils/version-from-zip-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ describe('Unit: Utils > versionFromZip', function () {
}).catch((error) => {
expect(error).to.be.an.instanceof(errors.SystemError);
expect(error.message).to.equal('Zip file contains a Ghost version incompatible with this version of the CLI.');
expect(error.options.help).to.equal('Required: v^0.0.1, current: v1.7.0');
expect(error.options.suggestion).to.equal('npm install -g ghost-cli@latest');
});
});

Expand Down

0 comments on commit 3a77ec8

Please sign in to comment.