Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
fix: display the invalid semver range as part of the error
Browse files Browse the repository at this point in the history
  • Loading branch information
dominykas committed Mar 14, 2019
1 parent f1e93b5 commit 04c92ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ exports.run = async (options) => {
packagesWithScripts
.forEach((entry) => {

const path = entry.path;
const childPkg = entry.childPkg;
const { path, childPkg } = entry;
const name = entry.childPkg.name;

if (allowScripts[name] === undefined) {
Expand All @@ -155,7 +154,7 @@ exports.run = async (options) => {
}

if (!Semver.validRange(allowScripts[name])) {
errors.push(`${name} (invalid semver range)`);
errors.push(`${name} (invalid semver range: ${allowScripts[name]})`);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ describe('allow-scripts', () => {
'without-scripts'
]);

await expect(Allow.run({})).to.reject('Mis-configured allowedScripts: @example/with-install-script (invalid semver range)');
await expect(Allow.run({})).to.reject('Mis-configured allowedScripts: @example/with-install-script (invalid semver range: not-a-semver-range)');

expect(fixture.getActualResult()).to.equal('');
expect(fixture.getLog()).to.equal('');
Expand Down

0 comments on commit 04c92ba

Please sign in to comment.