diff --git a/node_modules/bin-links/lib/link-mans.js b/node_modules/bin-links/lib/link-mans.js index 656e179b6ca54..b6dd214cebdfe 100644 --- a/node_modules/bin-links/lib/link-mans.js +++ b/node_modules/bin-links/lib/link-mans.js @@ -2,22 +2,23 @@ const { dirname, relative, join, resolve, basename } = require('path') const linkGently = require('./link-gently.js') const manTarget = require('./man-target.js') -const linkMans = ({ path, pkg, top, force }) => { +const linkMans = async ({ path, pkg, top, force }) => { const target = manTarget({ path, top }) - if (!target || !pkg.man || !Array.isArray(pkg.man) || !pkg.man.length) { - return Promise.resolve([]) + if (!target || !Array.isArray(pkg?.man) || !pkg.man.length) { + return [] } - // break any links to c:\\blah or /foo/blah or ../blah - // and filter out duplicates - const set = [...new Set(pkg.man.map(man => - man ? join('/', man).replace(/\\|:/g, '/').slice(1) : null) - .filter(man => typeof man === 'string'))] - - return Promise.all(set.map(man => { - const parseMan = man.match(/(.*\.([0-9]+)(\.gz)?)$/) + const links = [] + // `new Set` to filter out duplicates + for (let man of new Set(pkg.man)) { + if (!man || typeof man !== 'string') { + continue + } + // break any links to c:\\blah or /foo/blah or ../blah + man = join('/', man).replace(/\\|:/g, '/').slice(1) + const parseMan = man.match(/\.([0-9]+)(\.gz)?$/) if (!parseMan) { - return Promise.reject(Object.assign(new Error('invalid man entry name\n' + + throw Object.assign(new Error('invalid man entry name\n' + 'Man files must end with a number, ' + 'and optionally a .gz suffix if they are compressed.' ), { @@ -25,28 +26,28 @@ const linkMans = ({ path, pkg, top, force }) => { path, pkgid: pkg._id, man, - })) + }) } - const stem = parseMan[1] - const sxn = parseMan[2] - const base = basename(stem) + const section = parseMan[1] + const base = basename(man) const absFrom = resolve(path, man) /* istanbul ignore if - that unpossible */ if (absFrom.indexOf(path) !== 0) { - return Promise.reject(Object.assign(new Error('invalid man entry'), { + throw Object.assign(new Error('invalid man entry'), { code: 'EBADMAN', path, pkgid: pkg._id, man, - })) + }) } - const to = resolve(target, 'man' + sxn, base) + const to = resolve(target, 'man' + section, base) const from = relative(dirname(to), absFrom) - return linkGently({ from, to, path, absFrom, force }) - })) + links.push(linkGently({ from, to, path, absFrom, force })) + } + return Promise.all(links) } module.exports = linkMans diff --git a/node_modules/bin-links/package.json b/node_modules/bin-links/package.json index e6abb0b589808..d5c11f7971f94 100644 --- a/node_modules/bin-links/package.json +++ b/node_modules/bin-links/package.json @@ -1,6 +1,6 @@ { "name": "bin-links", - "version": "4.0.2", + "version": "4.0.3", "description": "JavaScript package binary linker", "main": "./lib/index.js", "scripts": { @@ -30,7 +30,7 @@ }, "devDependencies": { "@npmcli/eslint-config": "^4.0.0", - "@npmcli/template-oss": "4.15.1", + "@npmcli/template-oss": "4.19.0", "require-inject": "^1.4.4", "tap": "^16.0.1" }, @@ -53,7 +53,7 @@ "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", "windowsCI": false, - "version": "4.15.1", + "version": "4.19.0", "publish": true } } diff --git a/package-lock.json b/package-lock.json index dd69e0cb8ea0d..671201c3415ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4100,9 +4100,9 @@ } }, "node_modules/bin-links": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.2.tgz", - "integrity": "sha512-jxJ0PbXR8eQyPlExCvCs3JFnikvs1Yp4gUJt6nmgathdOwvur+q22KWC3h20gvWl4T/14DXKj2IlkJwwZkZPOw==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.3.tgz", + "integrity": "sha512-obsRaULtJurnfox/MDwgq6Yo9kzbv1CPTk/1/s7Z/61Lezc8IKkFCOXNeVLXz0456WRzBQmSsDWlai2tIhBsfA==", "dependencies": { "cmd-shim": "^6.0.0", "npm-normalize-package-bin": "^3.0.0",