Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2019-07-04 00:35:25 +0300
committerisaacs <i@izs.me>2019-07-04 00:35:43 +0300
commitf6164d5ddd072eabdf2237f1694a31efd746eb1d (patch)
tree83dd6e599db3b344020fb45c6f58e189c5b1d0b7 /node_modules/chownr
parent08e0fa6f18cc8ee94222c2825ee170091fe85f5c (diff)
chownr@1.1.2
This handles an EISDIR error from cacache on Darwin in Node versions prior to 10.6. Fix: [npm.community#7901](https://npm.community/t/7901/) Fix: [npm.community#8203](https://npm.community/t/8203/) Fix: https://github.com/isaacs/chownr/issues/20 PR-URL: https://github.com/isaacs/chownr/pull/21
Diffstat (limited to 'node_modules/chownr')
-rw-r--r--node_modules/chownr/chownr.js57
-rw-r--r--node_modules/chownr/package.json26
2 files changed, 61 insertions, 22 deletions
diff --git a/node_modules/chownr/chownr.js b/node_modules/chownr/chownr.js
index 7e6392882..b056912ee 100644
--- a/node_modules/chownr/chownr.js
+++ b/node_modules/chownr/chownr.js
@@ -7,6 +7,36 @@ const LCHOWN = fs.lchown ? 'lchown' : 'chown'
/* istanbul ignore next */
const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'
+const needEISDIRHandled = fs.lchown &&
+ !process.version.match(/v1[1-9]+\./) &&
+ !process.version.match(/v10\.[6-9]/)
+
+/* istanbul ignore next */
+const handleEISDIR =
+ needEISDIRHandled ? (path, uid, gid, cb) => er => {
+ // Node prior to v10 had a very questionable implementation of
+ // fs.lchown, which would always try to call fs.open on a directory
+ // Fall back to fs.chown in those cases.
+ if (!er || er.code !== 'EISDIR')
+ cb(er)
+ else
+ fs.chown(path, uid, gid, cb)
+ }
+ : (_, __, ___, cb) => cb
+
+/* istanbul ignore next */
+const handleEISDirSync =
+ needEISDIRHandled ? (path, uid, gid) => {
+ try {
+ return fs[LCHOWNSYNC](path, uid, gid)
+ } catch (er) {
+ if (er.code !== 'EISDIR')
+ throw er
+ fs.chownSync(path, uid, gid)
+ }
+ }
+ : fs[LCHOWNSYNC]
+
// fs.readdir could only accept an options object as of node v6
const nodeVersion = process.version
let readdir = (path, options, cb) => fs.readdir(path, options, cb)
@@ -28,10 +58,13 @@ const chownrKid = (p, child, uid, gid, cb) => {
chownr(path.resolve(p, child.name), uid, gid, er => {
if (er)
return cb(er)
- fs[LCHOWN](path.resolve(p, child.name), uid, gid, cb)
+ const cpath = path.resolve(p, child.name)
+ fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, cb))
})
- } else
- fs[LCHOWN](path.resolve(p, child.name), uid, gid, cb)
+ } else {
+ const cpath = path.resolve(p, child.name)
+ fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, cb))
+ }
}
@@ -41,14 +74,18 @@ const chownr = (p, uid, gid, cb) => {
// or doesn't exist. give up.
if (er && er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP')
return cb(er)
- if (er || !children.length) return fs[LCHOWN](p, uid, gid, cb)
+ if (er || !children.length)
+ return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb))
let len = children.length
let errState = null
const then = er => {
- if (errState) return
- if (er) return cb(errState = er)
- if (-- len === 0) return fs[LCHOWN](p, uid, gid, cb)
+ if (errState)
+ return
+ if (er)
+ return cb(errState = er)
+ if (-- len === 0)
+ return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb))
}
children.forEach(child => chownrKid(p, child, uid, gid, then))
@@ -65,7 +102,7 @@ const chownrKidSync = (p, child, uid, gid) => {
if (child.isDirectory())
chownrSync(path.resolve(p, child.name), uid, gid)
- fs[LCHOWNSYNC](path.resolve(p, child.name), uid, gid)
+ handleEISDirSync(path.resolve(p, child.name), uid, gid)
}
const chownrSync = (p, uid, gid) => {
@@ -74,14 +111,14 @@ const chownrSync = (p, uid, gid) => {
children = readdirSync(p, { withFileTypes: true })
} catch (er) {
if (er && er.code === 'ENOTDIR' && er.code !== 'ENOTSUP')
- return fs[LCHOWNSYNC](p, uid, gid)
+ return handleEISDirSync(p, uid, gid)
throw er
}
if (children.length)
children.forEach(child => chownrKidSync(p, child, uid, gid))
- return fs[LCHOWNSYNC](p, uid, gid)
+ return handleEISDirSync(p, uid, gid)
}
module.exports = chownr
diff --git a/node_modules/chownr/package.json b/node_modules/chownr/package.json
index 0004fa0e1..f7b9c81c8 100644
--- a/node_modules/chownr/package.json
+++ b/node_modules/chownr/package.json
@@ -1,28 +1,30 @@
{
- "_from": "chownr@1.1.1",
- "_id": "chownr@1.1.1",
+ "_from": "chownr@1.1.2",
+ "_id": "chownr@1.1.2",
"_inBundle": false,
- "_integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==",
+ "_integrity": "sha512-GkfeAQh+QNy3wquu9oIZr6SS5x7wGdSgNQvD10X3r+AZr1Oys22HW8kAmDMvNg2+Dm0TeGaEuO8gFwdBXxwO8A==",
"_location": "/chownr",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
- "raw": "chownr@1.1.1",
+ "raw": "chownr@1.1.2",
"name": "chownr",
"escapedName": "chownr",
- "rawSpec": "1.1.1",
+ "rawSpec": "1.1.2",
"saveSpec": null,
- "fetchSpec": "1.1.1"
+ "fetchSpec": "1.1.2"
},
"_requiredBy": [
"#USER",
- "/"
+ "/",
+ "/cacache",
+ "/tar"
],
- "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz",
- "_shasum": "54726b8b8fff4df053c42187e801fb4412df1494",
- "_spec": "chownr@1.1.1",
- "_where": "/Users/aeschright/code/cli",
+ "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.2.tgz",
+ "_shasum": "a18f1e0b269c8a6a5d3c86eb298beb14c3dd7bf6",
+ "_spec": "chownr@1.1.2",
+ "_where": "/Users/isaacs/dev/npm/cli",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
@@ -56,5 +58,5 @@
"preversion": "npm test",
"test": "tap test/*.js --cov"
},
- "version": "1.1.1"
+ "version": "1.1.2"
}