diff options
author | isaacs <i@izs.me> | 2019-12-11 21:53:32 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2019-12-11 21:54:07 +0300 |
commit | d06f5c0b0611c43b6e70ded92af24fa5d83a0f48 (patch) | |
tree | 9bf2e6fa5e5fcae004d4945b3e976fd7d662adfe /node_modules/bin-links | |
parent | 52fd21061ff8b1a73429294620ffe5ebaaa60d3e (diff) |
bin-links@1.1.6
Diffstat (limited to 'node_modules/bin-links')
-rw-r--r-- | node_modules/bin-links/CHANGELOG.md | 10 | ||||
-rw-r--r-- | node_modules/bin-links/index.js | 30 | ||||
-rw-r--r-- | node_modules/bin-links/package.json | 26 |
3 files changed, 44 insertions, 22 deletions
diff --git a/node_modules/bin-links/CHANGELOG.md b/node_modules/bin-links/CHANGELOG.md index 7966938ae..697e3c535 100644 --- a/node_modules/bin-links/CHANGELOG.md +++ b/node_modules/bin-links/CHANGELOG.md @@ -2,6 +2,16 @@ 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) diff --git a/node_modules/bin-links/index.js b/node_modules/bin-links/index.js index eda6abd19..4f6d3c055 100644 --- a/node_modules/bin-links/index.js +++ b/node_modules/bin-links/index.js @@ -3,8 +3,9 @@ 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}) @@ -42,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) { @@ -109,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 }) @@ -116,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) { @@ -132,17 +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) { + 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) { + 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) { @@ -165,6 +172,11 @@ function linkMans (pkg, folder, parent, gtop, opts) { 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/node_modules/bin-links/package.json b/node_modules/bin-links/package.json index 71c3ee3fc..a4d2c0222 100644 --- a/node_modules/bin-links/package.json +++ b/node_modules/bin-links/package.json @@ -1,19 +1,19 @@ { - "_from": "bin-links@1.1.5", - "_id": "bin-links@1.1.5", + "_from": "bin-links@1.1.6", + "_id": "bin-links@1.1.6", "_inBundle": false, - "_integrity": "sha512-GQuxeiclIjomNfQ7LSaERfIz2RSZrF44c0cDEV+Iu4uVhyYndSSwl1RjjunxHU1dYqh+QCP4S/1/DUsjquNRhQ==", + "_integrity": "sha512-b5rV3uVyrlrJWLI3mawUUf5t2f9mCEQm/TqT5zNj6DPYhYDZaNp0AYaYd/CVASkSEklayNDLliZHVdo2J3niPw==", "_location": "/bin-links", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "bin-links@1.1.5", + "raw": "bin-links@1.1.6", "name": "bin-links", "escapedName": "bin-links", - "rawSpec": "1.1.5", + "rawSpec": "1.1.6", "saveSpec": null, - "fetchSpec": "1.1.5" + "fetchSpec": "1.1.6" }, "_requiredBy": [ "#USER", @@ -21,9 +21,9 @@ "/libcipm", "/libnpm" ], - "_resolved": "https://registry.npmjs.org/bin-links/-/bin-links-1.1.5.tgz", - "_shasum": "bbbcd1d7a8101105b927d54aa895a4cc75138169", - "_spec": "bin-links@1.1.5", + "_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,7 +35,7 @@ "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" @@ -70,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.5" + "version": "1.1.6" } |