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

Commit 04c92ba

Browse files
committed
fix: display the invalid semver range as part of the error
1 parent f1e93b5 commit 04c92ba

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ exports.run = async (options) => {
135135
packagesWithScripts
136136
.forEach((entry) => {
137137

138-
const path = entry.path;
139-
const childPkg = entry.childPkg;
138+
const { path, childPkg } = entry;
140139
const name = entry.childPkg.name;
141140

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

157156
if (!Semver.validRange(allowScripts[name])) {
158-
errors.push(`${name} (invalid semver range)`);
157+
errors.push(`${name} (invalid semver range: ${allowScripts[name]})`);
159158
return;
160159
}
161160

test/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ describe('allow-scripts', () => {
190190
'without-scripts'
191191
]);
192192

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

195195
expect(fixture.getActualResult()).to.equal('');
196196
expect(fixture.getLog()).to.equal('');

0 commit comments

Comments
 (0)