diff --git a/lib/internal/policy/manifest.js b/lib/internal/policy/manifest.js index 42ff63e87dc9cf..a601113182674e 100644 --- a/lib/internal/policy/manifest.js +++ b/lib/internal/policy/manifest.js @@ -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]; diff --git a/test/fixtures/policy-manifest/invalid.json b/test/fixtures/policy-manifest/invalid.json new file mode 100644 index 00000000000000..a8a0deb2cf7e07 --- /dev/null +++ b/test/fixtures/policy-manifest/invalid.json @@ -0,0 +1,9 @@ +{ + "resources": { + "./fhqwhgads.js": { + "dependencies": { + "**": true + } + } + } +} diff --git a/test/parallel/test-policy-manifest.js b/test/parallel/test-policy-manifest.js new file mode 100644 index 00000000000000..a8494175f3e68f --- /dev/null +++ b/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 "\*"/);