bin-links
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -5,18 +5,19 @@ const { dirname, relative, join, resolve, basename } = require('path') | ||
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, ' + | ||
@@ -29,12 +30,11 @@ 'and optionally a .gz suffix if they are compressed.' | ||
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', | ||
@@ -44,12 +44,13 @@ path, | ||
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 |
{ | ||
"name": "bin-links", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "JavaScript package binary linker", | ||
@@ -33,3 +33,3 @@ "main": "./lib/index.js", | ||
"@npmcli/eslint-config": "^4.0.0", | ||
"@npmcli/template-oss": "4.15.1", | ||
"@npmcli/template-oss": "4.19.0", | ||
"require-inject": "^1.4.4", | ||
@@ -57,5 +57,5 @@ "tap": "^16.0.1" | ||
"windowsCI": false, | ||
"version": "4.15.1", | ||
"version": "4.19.0", | ||
"publish": true | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
448
0
20646