diff options
author | Michael Perrotte <mike@npmjs.com> | 2020-01-31 23:59:21 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-05-08 04:11:51 +0300 |
commit | 56e1f868e8634a4bf0f7a7186a68a6f3de9cfb2a (patch) | |
tree | f05cdcb56d66480641b6c8f8bb823bc10c6842df /node_modules/chownr | |
parent | 8f6b6204f9cdbfc8e2a27a1c3b3f1591ac7e0d60 (diff) |
npm-pick-manifest@6.0.0
Diffstat (limited to 'node_modules/chownr')
-rw-r--r-- | node_modules/chownr/chownr.js | 74 | ||||
-rw-r--r-- | node_modules/chownr/package.json | 33 |
2 files changed, 31 insertions, 76 deletions
diff --git a/node_modules/chownr/chownr.js b/node_modules/chownr/chownr.js index 0d4093216..9f04393b7 100644 --- a/node_modules/chownr/chownr.js +++ b/node_modules/chownr/chownr.js @@ -7,30 +7,10 @@ const LCHOWN = fs.lchown ? 'lchown' : 'chown' /* istanbul ignore next */ const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync' -/* istanbul ignore next */ const needEISDIRHandled = fs.lchown && !process.version.match(/v1[1-9]+\./) && !process.version.match(/v10\.[6-9]/) -const lchownSync = (path, uid, gid) => { - try { - return fs[LCHOWNSYNC](path, uid, gid) - } catch (er) { - if (er.code !== 'ENOENT') - throw er - } -} - -/* istanbul ignore next */ -const chownSync = (path, uid, gid) => { - try { - return fs.chownSync(path, uid, gid) - } catch (er) { - if (er.code !== 'ENOENT') - throw er - } -} - /* istanbul ignore next */ const handleEISDIR = needEISDIRHandled ? (path, uid, gid, cb) => er => { @@ -48,14 +28,14 @@ const handleEISDIR = const handleEISDirSync = needEISDIRHandled ? (path, uid, gid) => { try { - return lchownSync(path, uid, gid) + return fs[LCHOWNSYNC](path, uid, gid) } catch (er) { if (er.code !== 'EISDIR') throw er - chownSync(path, uid, gid) + fs.chownSync(path, uid, gid) } } - : (path, uid, gid) => lchownSync(path, uid, gid) + : (path, uid, gid) => fs[LCHOWNSYNC](path, uid, gid) // fs.readdir could only accept an options object as of node v6 const nodeVersion = process.version @@ -65,19 +45,11 @@ let readdirSync = (path, options) => fs.readdirSync(path, options) if (/^v4\./.test(nodeVersion)) readdir = (path, options, cb) => fs.readdir(path, cb) -const chown = (cpath, uid, gid, cb) => { - fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, er => { - // Skip ENOENT error - cb(er && er.code !== 'ENOENT' ? er : null) - })) -} - const chownrKid = (p, child, uid, gid, cb) => { if (typeof child === 'string') return fs.lstat(path.resolve(p, child), (er, stats) => { - // Skip ENOENT error if (er) - return cb(er.code !== 'ENOENT' ? er : null) + return cb(er) stats.name = child chownrKid(p, stats, uid, gid, cb) }) @@ -87,11 +59,11 @@ const chownrKid = (p, child, uid, gid, cb) => { if (er) return cb(er) const cpath = path.resolve(p, child.name) - chown(cpath, uid, gid, cb) + fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, cb)) }) } else { const cpath = path.resolve(p, child.name) - chown(cpath, uid, gid, cb) + fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, cb)) } } @@ -100,14 +72,10 @@ const chownr = (p, uid, gid, cb) => { readdir(p, { withFileTypes: true }, (er, children) => { // any error other than ENOTDIR or ENOTSUP means it's not readable, // or doesn't exist. give up. - if (er) { - if (er.code === 'ENOENT') - return cb() - else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP') - return cb(er) - } + if (er && er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP') + return cb(er) if (er || !children.length) - return chown(p, uid, gid, cb) + return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb)) let len = children.length let errState = null @@ -117,7 +85,7 @@ const chownr = (p, uid, gid, cb) => { if (er) return cb(errState = er) if (-- len === 0) - return chown(p, uid, gid, cb) + return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb)) } children.forEach(child => chownrKid(p, child, uid, gid, then)) @@ -126,16 +94,9 @@ const chownr = (p, uid, gid, cb) => { const chownrKidSync = (p, child, uid, gid) => { if (typeof child === 'string') { - try { - const stats = fs.lstatSync(path.resolve(p, child)) - stats.name = child - child = stats - } catch (er) { - if (er.code === 'ENOENT') - return - else - throw er - } + const stats = fs.lstatSync(path.resolve(p, child)) + stats.name = child + child = stats } if (child.isDirectory()) @@ -149,15 +110,12 @@ const chownrSync = (p, uid, gid) => { try { children = readdirSync(p, { withFileTypes: true }) } catch (er) { - if (er.code === 'ENOENT') - return - else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP') + if (er && er.code === 'ENOTDIR' && er.code !== 'ENOTSUP') return handleEISDirSync(p, uid, gid) - else - throw er + throw er } - if (children && children.length) + if (children.length) children.forEach(child => chownrKidSync(p, child, uid, gid)) return handleEISDirSync(p, uid, gid) diff --git a/node_modules/chownr/package.json b/node_modules/chownr/package.json index 5c125f844..cc48dc912 100644 --- a/node_modules/chownr/package.json +++ b/node_modules/chownr/package.json @@ -1,19 +1,19 @@ { - "_from": "chownr@1.1.4", - "_id": "chownr@1.1.4", + "_from": "chownr@1.1.3", + "_id": "chownr@1.1.3", "_inBundle": false, - "_integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", + "_integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==", "_location": "/chownr", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "chownr@1.1.4", + "raw": "chownr@1.1.3", "name": "chownr", "escapedName": "chownr", - "rawSpec": "1.1.4", + "rawSpec": "1.1.3", "saveSpec": null, - "fetchSpec": "1.1.4" + "fetchSpec": "1.1.3" }, "_requiredBy": [ "#USER", @@ -23,10 +23,10 @@ "/pacote", "/tar" ], - "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "_shasum": "6fc9d7b42d32a583596337666e7d08084da2cc6b", - "_spec": "chownr@1.1.4", - "_where": "/Users/darcyclarke/Documents/Repos/npm/cli", + "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", + "_shasum": "42d837d5239688d55f303003a508230fa6727142", + "_spec": "chownr@1.1.3", + "_where": "/Users/mperrotte/npminc/cli", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -40,8 +40,8 @@ "description": "like `chown -R`", "devDependencies": { "mkdirp": "0.3", - "rimraf": "^2.7.1", - "tap": "^14.10.6" + "rimraf": "", + "tap": "^12.0.1" }, "files": [ "chownr.js" @@ -55,13 +55,10 @@ "url": "git://github.com/isaacs/chownr.git" }, "scripts": { + "postpublish": "git push origin --follow-tags", "postversion": "npm publish", - "prepublishOnly": "git push origin --follow-tags", "preversion": "npm test", - "test": "tap" + "test": "tap test/*.js --cov" }, - "tap": { - "check-coverage": true - }, - "version": "1.1.4" + "version": "1.1.3" } |