Skip to content

Commit

Permalink
Improve error message for assertSingleImpelementation finds no depend…
Browse files Browse the repository at this point in the history
…encies.
  • Loading branch information
stefanpenner committed Feb 14, 2020
1 parent 8c66659 commit f0f9d4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/project-wide-dependency-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,16 @@ module.exports = class ProjectWideDependencyChecker {
return true;
}

let message =
customMessage ||
`[ember-cli-version-checker] This project requires a single implementation version of the npm package \`${name}\`, but there're multiple. Please resolve \`${name}\` to same version:`;

let message;
if (uniqueImplementations.size < 1) {
message = `[ember-cli-version-checker] This project requires a single implementation version of the npm package \`${name}\`, but none where found.`;
} else {
if (customMessage) {
message = customMessage;
} else {
message = `[ember-cli-version-checker] This project requires a single implementation version of the npm package \`${name}\`, but there're multiple. Please resolve \`${name}\` to same version:`;
}
}
for (let root of uniqueImplementations) {
message += `\n - ${name} @ ${root}`;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/index-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,9 @@ describe('ember-cli-version-checker', function() {
});

it('#assertSingleImplementation throws correctly', function() {
assert.throws(() => {
checker.assertSingleImplementation('--no-such-addon--');
}, /This project requires a single implementation version of the npm package `--no-such-addon--`, but none where found./);
assert.throws(() => {
checker.assertSingleImplementation('bar');
}, /This project requires a single implementation version of the npm package `bar`, but there're multiple. Please resolve `bar` to same version./);
Expand Down

0 comments on commit f0f9d4a

Please sign in to comment.