Skip to content

Commit b320387

Browse files
Trotttargos
authored andcommitted
policy: fix message for invalid manifest specifier
Add test for invalid manifest specifier and fix the error message which is missing a space ("singletrailing" instead of "single trailing"). PR-URL: #40574 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Zijian Liu <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Voltrex <[email protected]>
1 parent 075cfbf commit b320387

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

lib/internal/policy/manifest.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ class DependencyMapperInstance {
136136
if (!target) {
137137
throw new ERR_MANIFEST_INVALID_SPECIFIER(
138138
this.href,
139-
target +
140-
', pattern needs to have a single' +
141-
'trailing "*" in target');
139+
`${target}, pattern needs to have a single trailing "*" in target`
140+
);
142141
}
143142
const prefix = target[1];
144143
const suffix = target[2];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"resources": {
3+
"./fhqwhgads.js": {
4+
"dependencies": {
5+
"**": true
6+
}
7+
}
8+
}
9+
}

test/parallel/test-policy-manifest.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
7+
8+
common.requireNoPackageJSONAbove();
9+
10+
const assert = require('assert');
11+
const { spawnSync } = require('child_process');
12+
const fixtures = require('../common/fixtures.js');
13+
14+
const policyFilepath = fixtures.path('policy-manifest', 'invalid.json');
15+
16+
const result = spawnSync(process.execPath, [
17+
'--experimental-policy',
18+
policyFilepath,
19+
'./fhqwhgads.js',
20+
]);
21+
22+
assert.notStrictEqual(result.status, 0);
23+
const stderr = result.stderr.toString();
24+
assert.match(stderr, /ERR_MANIFEST_INVALID_SPECIFIER/);
25+
assert.match(stderr, /pattern needs to have a single trailing "\*"/);

0 commit comments

Comments
 (0)