Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

policy: fix message for invalid manifest specifier #40574

Merged
merged 1 commit into from Oct 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/internal/policy/manifest.js
Expand Up @@ -136,9 +136,8 @@ class DependencyMapperInstance {
if (!target) {
throw new ERR_MANIFEST_INVALID_SPECIFIER(
this.href,
target +
', pattern needs to have a single' +
'trailing "*" in target');
`${target}, pattern needs to have a single trailing "*" in target`
);
}
const prefix = target[1];
const suffix = target[2];
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/policy-manifest/invalid.json
@@ -0,0 +1,9 @@
{
"resources": {
"./fhqwhgads.js": {
"dependencies": {
"**": true
}
}
}
}
25 changes: 25 additions & 0 deletions test/parallel/test-policy-manifest.js
@@ -0,0 +1,25 @@
'use strict';

const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

common.requireNoPackageJSONAbove();

const assert = require('assert');
const { spawnSync } = require('child_process');
const fixtures = require('../common/fixtures.js');

const policyFilepath = fixtures.path('policy-manifest', 'invalid.json');

const result = spawnSync(process.execPath, [
'--experimental-policy',
policyFilepath,
'./fhqwhgads.js',
]);

assert.notStrictEqual(result.status, 0);
const stderr = result.stderr.toString();
assert.match(stderr, /ERR_MANIFEST_INVALID_SPECIFIER/);
assert.match(stderr, /pattern needs to have a single trailing "\*"/);