diff options
Diffstat (limited to 'deps/npm/node_modules/bin-links')
-rw-r--r-- | deps/npm/node_modules/bin-links/CHANGELOG.md | 30 | ||||
-rw-r--r-- | deps/npm/node_modules/bin-links/index.js | 51 | ||||
-rw-r--r-- | deps/npm/node_modules/bin-links/package.json | 27 |
3 files changed, 84 insertions, 24 deletions
diff --git a/deps/npm/node_modules/bin-links/CHANGELOG.md b/deps/npm/node_modules/bin-links/CHANGELOG.md index e529302788..697e3c5355 100644 --- a/deps/npm/node_modules/bin-links/CHANGELOG.md +++ b/deps/npm/node_modules/bin-links/CHANGELOG.md @@ -2,6 +2,36 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +<a name="1.1.6"></a> +## [1.1.6](https://github.com/npm/bin-links/compare/v1.1.5...v1.1.6) (2019-12-11) + + +### Bug Fixes + +* prevent improper clobbering of man/bin links ([642cd18](https://github.com/npm/bin-links/commit/642cd18)), closes [#11](https://github.com/npm/bin-links/issues/11) [#12](https://github.com/npm/bin-links/issues/12) + + + +<a name="1.1.5"></a> +## [1.1.5](https://github.com/npm/bin-links/compare/v1.1.4...v1.1.5) (2019-12-10) + + +### Bug Fixes + +* don't filter out ./ man references ([b3cfd2e](https://github.com/npm/bin-links/commit/b3cfd2e)) + + + +<a name="1.1.4"></a> +## [1.1.4](https://github.com/npm/bin-links/compare/v1.1.3...v1.1.4) (2019-12-09) + + +### Bug Fixes + +* sanitize and validate bin and man link targets ([25a34f9](https://github.com/npm/bin-links/commit/25a34f9)) + + + <a name="1.1.3"></a> ## [1.1.3](https://github.com/npm/bin-links/compare/v1.1.2...v1.1.3) (2019-08-14) diff --git a/deps/npm/node_modules/bin-links/index.js b/deps/npm/node_modules/bin-links/index.js index 5f86755475..4f6d3c055c 100644 --- a/deps/npm/node_modules/bin-links/index.js +++ b/deps/npm/node_modules/bin-links/index.js @@ -3,18 +3,22 @@ const path = require('path') const fs = require('graceful-fs') const BB = require('bluebird') -const linkIfExists = BB.promisify(require('gentle-fs').linkIfExists) -const cmdShimIfExists = BB.promisify(require('cmd-shim').ifExists) +const gentleFs = require('gentle-fs') +const linkIfExists = BB.promisify(gentleFs.linkIfExists) +const gentleFsBinLink = BB.promisify(gentleFs.binLink) const open = BB.promisify(fs.open) const close = BB.promisify(fs.close) const read = BB.promisify(fs.read, {multiArgs: true}) const chmod = BB.promisify(fs.chmod) const readFile = BB.promisify(fs.readFile) const writeFileAtomic = BB.promisify(require('write-file-atomic')) +const normalize = require('npm-normalize-package-bin') module.exports = BB.promisify(binLinks) function binLinks (pkg, folder, global, opts, cb) { + pkg = normalize(pkg) + // if it's global, and folder is in {prefix}/node_modules, // then bins are in {prefix}/bin // otherwise, then bins are in folder/../.bin @@ -39,9 +43,9 @@ function isHashbangFile (file) { return read(fileHandle, Buffer.alloc(2), 0, 2, 0).spread((_, buf) => { if (!hasHashbang(buf)) return [] return read(fileHandle, Buffer.alloc(2048), 0, 2048, 0) - }).spread((_, buf) => buf && hasCR(buf), () => false) + }).spread((_, buf) => buf && hasCR(buf), /* istanbul ignore next */ () => false) .finally(() => close(fileHandle)) - }).catch(() => false) + }).catch(/* istanbul ignore next */ () => false) } function hasHashbang (buf) { @@ -77,6 +81,12 @@ function linkBins (pkg, folder, parent, gtop, opts) { var dest = path.resolve(binRoot, bin) var src = path.resolve(folder, pkg.bin[bin]) + /* istanbul ignore if - that unpossible */ + if (src.indexOf(folder) !== 0) { + throw new Error('invalid bin entry for package ' + + pkg._id + '. key=' + bin + ', value=' + pkg.bin[bin]) + } + return linkBin(src, dest, linkOpts).then(() => { // bins should always be executable. // XXX skip chmod on windows? @@ -100,6 +110,7 @@ function linkBins (pkg, folder, parent, gtop, opts) { opts.log.showProgress() } }).catch(err => { + /* istanbul ignore next */ if (err.code === 'ENOENT' && opts.ignoreScripts) return throw err }) @@ -107,11 +118,11 @@ function linkBins (pkg, folder, parent, gtop, opts) { } function linkBin (from, to, opts) { - if (process.platform !== 'win32') { - return linkIfExists(from, to, opts) - } else { - return cmdShimIfExists(from, to) + // do not clobber global bins + if (opts.globalBin && to.indexOf(opts.globalBin) === 0) { + opts.clobberLinkGently = true } + return gentleFsBinLink(from, to, opts) } function linkMans (pkg, folder, parent, gtop, opts) { @@ -123,15 +134,22 @@ function linkMans (pkg, folder, parent, gtop, opts) { // make sure that the mans are unique. // otherwise, if there are dupes, it'll fail with EEXIST var set = pkg.man.reduce(function (acc, man) { - acc[path.basename(man)] = man + if (typeof man !== 'string') { + return acc + } + const cleanMan = path.join('/', man).replace(/\\|:/g, '/').substr(1) + acc[path.basename(man)] = cleanMan return acc }, {}) var manpages = pkg.man.filter(function (man) { - return set[path.basename(man)] === man + if (typeof man !== 'string') { + return false + } + const cleanMan = path.join('/', man).replace(/\\|:/g, '/').substr(1) + return set[path.basename(man)] === cleanMan }) return BB.map(manpages, man => { - if (typeof man !== 'string') return opts.log.silly('linkMans', 'preparing to link', man) var parseMan = man.match(/(.*\.([0-9]+)(\.gz)?)$/) if (!parseMan) { @@ -146,8 +164,19 @@ function linkMans (pkg, folder, parent, gtop, opts) { var sxn = parseMan[2] var bn = path.basename(stem) var manSrc = path.resolve(folder, man) + /* istanbul ignore if - that unpossible */ + if (manSrc.indexOf(folder) !== 0) { + throw new Error('invalid man entry for package ' + + pkg._id + '. man=' + manSrc) + } + var manDest = path.join(manRoot, 'man' + sxn, bn) + // man pages should always be clobbering gently, because they are + // only installed for top-level global packages, so never destroy + // a link if it doesn't point into the folder we're linking + opts.clobberLinkGently = true + return linkIfExists(manSrc, manDest, getLinkOpts(opts, gtop && folder)) }) } diff --git a/deps/npm/node_modules/bin-links/package.json b/deps/npm/node_modules/bin-links/package.json index e14be1e692..a4d2c02226 100644 --- a/deps/npm/node_modules/bin-links/package.json +++ b/deps/npm/node_modules/bin-links/package.json @@ -1,19 +1,19 @@ { - "_from": "bin-links@1.1.3", - "_id": "bin-links@1.1.3", + "_from": "bin-links@1.1.6", + "_id": "bin-links@1.1.6", "_inBundle": false, - "_integrity": "sha512-TEwmH4PHU/D009stP+fkkazMJgkBNCv60z01lQ/Mn8E6+ThHoD03svMnBVuCowwXo2nP2qKyKZxKxp58OHRzxw==", + "_integrity": "sha512-b5rV3uVyrlrJWLI3mawUUf5t2f9mCEQm/TqT5zNj6DPYhYDZaNp0AYaYd/CVASkSEklayNDLliZHVdo2J3niPw==", "_location": "/bin-links", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "bin-links@1.1.3", + "raw": "bin-links@1.1.6", "name": "bin-links", "escapedName": "bin-links", - "rawSpec": "1.1.3", + "rawSpec": "1.1.6", "saveSpec": null, - "fetchSpec": "1.1.3" + "fetchSpec": "1.1.6" }, "_requiredBy": [ "#USER", @@ -21,9 +21,9 @@ "/libcipm", "/libnpm" ], - "_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.1.3.tgz", - "_shasum": "702fd59552703727313bc624bdbc4c0d3431c2ca", - "_spec": "bin-links@1.1.3", + "_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.1.6.tgz", + "_shasum": "30d33e810829305e5e61b90cfcb9a3a4f65eb516", + "_spec": "bin-links@1.1.6", "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Mike Sherov" @@ -35,8 +35,9 @@ "dependencies": { "bluebird": "^3.5.3", "cmd-shim": "^3.0.0", - "gentle-fs": "^2.0.1", + "gentle-fs": "^2.3.0", "graceful-fs": "^4.1.15", + "npm-normalize-package-bin": "^1.0.0", "write-file-atomic": "^2.3.0" }, "deprecated": false, @@ -69,12 +70,12 @@ }, "scripts": { "postrelease": "npm publish && git push --follow-tags", + "posttest": "standard", "prerelease": "npm t", - "pretest": "standard", "release": "standard-version -s", - "test": "tap -J --nyc-arg=--all --coverage test/*.js", + "test": "tap -J --nyc-arg=--all --coverage test/*.js --100", "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "1.1.3" + "version": "1.1.6" } |