Skip to content

Commit 3e298f6

Browse files
committed
1 parent 35a6286 commit 3e298f6

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

node_modules/bin-links/lib/link-mans.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,52 @@ const { dirname, relative, join, resolve, basename } = require('path')
22
const linkGently = require('./link-gently.js')
33
const manTarget = require('./man-target.js')
44

5-
const linkMans = ({ path, pkg, top, force }) => {
5+
const linkMans = async ({ path, pkg, top, force }) => {
66
const target = manTarget({ path, top })
7-
if (!target || !pkg.man || !Array.isArray(pkg.man) || !pkg.man.length) {
8-
return Promise.resolve([])
7+
if (!target || !Array.isArray(pkg?.man) || !pkg.man.length) {
8+
return []
99
}
1010

11-
// break any links to c:\\blah or /foo/blah or ../blah
12-
// and filter out duplicates
13-
const set = [...new Set(pkg.man.map(man =>
14-
man ? join('/', man).replace(/\\|:/g, '/').slice(1) : null)
15-
.filter(man => typeof man === 'string'))]
16-
17-
return Promise.all(set.map(man => {
18-
const parseMan = man.match(/(.*\.([0-9]+)(\.gz)?)$/)
11+
const links = []
12+
// `new Set` to filter out duplicates
13+
for (let man of new Set(pkg.man)) {
14+
if (!man || typeof man !== 'string') {
15+
continue
16+
}
17+
// break any links to c:\\blah or /foo/blah or ../blah
18+
man = join('/', man).replace(/\\|:/g, '/').slice(1)
19+
const parseMan = man.match(/\.([0-9]+)(\.gz)?$/)
1920
if (!parseMan) {
20-
return Promise.reject(Object.assign(new Error('invalid man entry name\n' +
21+
throw Object.assign(new Error('invalid man entry name\n' +
2122
'Man files must end with a number, ' +
2223
'and optionally a .gz suffix if they are compressed.'
2324
), {
2425
code: 'EBADMAN',
2526
path,
2627
pkgid: pkg._id,
2728
man,
28-
}))
29+
})
2930
}
3031

31-
const stem = parseMan[1]
32-
const sxn = parseMan[2]
33-
const base = basename(stem)
32+
const section = parseMan[1]
33+
const base = basename(man)
3434
const absFrom = resolve(path, man)
3535
/* istanbul ignore if - that unpossible */
3636
if (absFrom.indexOf(path) !== 0) {
37-
return Promise.reject(Object.assign(new Error('invalid man entry'), {
37+
throw Object.assign(new Error('invalid man entry'), {
3838
code: 'EBADMAN',
3939
path,
4040
pkgid: pkg._id,
4141
man,
42-
}))
42+
})
4343
}
4444

45-
const to = resolve(target, 'man' + sxn, base)
45+
const to = resolve(target, 'man' + section, base)
4646
const from = relative(dirname(to), absFrom)
4747

48-
return linkGently({ from, to, path, absFrom, force })
49-
}))
48+
links.push(linkGently({ from, to, path, absFrom, force }))
49+
}
50+
return Promise.all(links)
5051
}
5152

5253
module.exports = linkMans

node_modules/bin-links/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bin-links",
3-
"version": "4.0.2",
3+
"version": "4.0.3",
44
"description": "JavaScript package binary linker",
55
"main": "./lib/index.js",
66
"scripts": {
@@ -30,7 +30,7 @@
3030
},
3131
"devDependencies": {
3232
"@npmcli/eslint-config": "^4.0.0",
33-
"@npmcli/template-oss": "4.15.1",
33+
"@npmcli/template-oss": "4.19.0",
3434
"require-inject": "^1.4.4",
3535
"tap": "^16.0.1"
3636
},
@@ -53,7 +53,7 @@
5353
"templateOSS": {
5454
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
5555
"windowsCI": false,
56-
"version": "4.15.1",
56+
"version": "4.19.0",
5757
"publish": true
5858
}
5959
}

package-lock.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,8 +3654,9 @@
36543654
}
36553655
},
36563656
"node_modules/bin-links": {
3657-
"version": "4.0.2",
3658-
"license": "ISC",
3657+
"version": "4.0.3",
3658+
"resolved": "https://registry.npmjs.org/bin-links/-/bin-links-4.0.3.tgz",
3659+
"integrity": "sha512-obsRaULtJurnfox/MDwgq6Yo9kzbv1CPTk/1/s7Z/61Lezc8IKkFCOXNeVLXz0456WRzBQmSsDWlai2tIhBsfA==",
36593660
"dependencies": {
36603661
"cmd-shim": "^6.0.0",
36613662
"npm-normalize-package-bin": "^3.0.0",

0 commit comments

Comments
 (0)