diff options
author | isaacs <i@izs.me> | 2020-07-11 04:19:53 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-07-29 21:53:10 +0300 |
commit | e46400c9484f5c66a0ba405eeb8c1340594dbf05 (patch) | |
tree | 1c3c13d9024752c4b3dc129e2f86c7963544c5a4 /node_modules/chownr | |
parent | 73657ae140810da50847d0ff729ddbab99ba5aac (diff) |
update dependencies, refactor config loading to async
This removes a lot of very outdated dependencies, updates many to
their modern (usually promisified) versions, and updates (or removes)
code to account for the change.
Several dependencies have been completely removed, and others a bit
shuffled around, so that the node_modules folder can be bundled somewhat
more optimally than it would have otherwise.
Diffstat (limited to 'node_modules/chownr')
-rw-r--r-- | node_modules/chownr/chownr.js | 74 | ||||
-rw-r--r-- | node_modules/chownr/package.json | 44 |
2 files changed, 81 insertions, 37 deletions
diff --git a/node_modules/chownr/chownr.js b/node_modules/chownr/chownr.js index 9f04393b7..0d4093216 100644 --- a/node_modules/chownr/chownr.js +++ b/node_modules/chownr/chownr.js @@ -7,10 +7,30 @@ 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 => { @@ -28,14 +48,14 @@ const handleEISDIR = const handleEISDirSync = needEISDIRHandled ? (path, uid, gid) => { try { - return fs[LCHOWNSYNC](path, uid, gid) + return lchownSync(path, uid, gid) } catch (er) { if (er.code !== 'EISDIR') throw er - fs.chownSync(path, uid, gid) + chownSync(path, uid, gid) } } - : (path, uid, gid) => fs[LCHOWNSYNC](path, uid, gid) + : (path, uid, gid) => lchownSync(path, uid, gid) // fs.readdir could only accept an options object as of node v6 const nodeVersion = process.version @@ -45,11 +65,19 @@ 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) + return cb(er.code !== 'ENOENT' ? er : null) stats.name = child chownrKid(p, stats, uid, gid, cb) }) @@ -59,11 +87,11 @@ const chownrKid = (p, child, uid, gid, cb) => { if (er) return cb(er) const cpath = path.resolve(p, child.name) - fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, cb)) + chown(cpath, uid, gid, cb) }) } else { const cpath = path.resolve(p, child.name) - fs[LCHOWN](cpath, uid, gid, handleEISDIR(cpath, uid, gid, cb)) + chown(cpath, uid, gid, cb) } } @@ -72,10 +100,14 @@ 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 && er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP') - return cb(er) + if (er) { + if (er.code === 'ENOENT') + return cb() + else if (er.code !== 'ENOTDIR' && er.code !== 'ENOTSUP') + return cb(er) + } if (er || !children.length) - return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb)) + return chown(p, uid, gid, cb) let len = children.length let errState = null @@ -85,7 +117,7 @@ const chownr = (p, uid, gid, cb) => { if (er) return cb(errState = er) if (-- len === 0) - return fs[LCHOWN](p, uid, gid, handleEISDIR(p, uid, gid, cb)) + return chown(p, uid, gid, cb) } children.forEach(child => chownrKid(p, child, uid, gid, then)) @@ -94,9 +126,16 @@ const chownr = (p, uid, gid, cb) => { const chownrKidSync = (p, child, uid, gid) => { if (typeof child === 'string') { - const stats = fs.lstatSync(path.resolve(p, child)) - stats.name = child - child = stats + try { + const stats = fs.lstatSync(path.resolve(p, child)) + stats.name = child + child = stats + } catch (er) { + if (er.code === 'ENOENT') + return + else + throw er + } } if (child.isDirectory()) @@ -110,12 +149,15 @@ const chownrSync = (p, uid, gid) => { try { children = readdirSync(p, { withFileTypes: true }) } catch (er) { - if (er && er.code === 'ENOTDIR' && er.code !== 'ENOTSUP') + if (er.code === 'ENOENT') + return + else if (er.code === 'ENOTDIR' || er.code === 'ENOTSUP') return handleEISDirSync(p, uid, gid) - throw er + else + throw er } - if (children.length) + if (children && 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 cc48dc912..f12ea9560 100644 --- a/node_modules/chownr/package.json +++ b/node_modules/chownr/package.json @@ -1,32 +1,28 @@ { - "_from": "chownr@1.1.3", - "_id": "chownr@1.1.3", + "_from": "chownr@latest", + "_id": "chownr@2.0.0", "_inBundle": false, - "_integrity": "sha512-i70fVHhmV3DtTl6nqvZOnIjbY0Pe4kAUjwHj8z0zAdgBtYrJyYwLKCCuRBQ5ppkyL0AkN7HKRnETdmdp1zqNXw==", + "_integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", "_location": "/chownr", "_phantomChildren": {}, "_requested": { - "type": "version", + "type": "tag", "registry": true, - "raw": "chownr@1.1.3", + "raw": "chownr@latest", "name": "chownr", "escapedName": "chownr", - "rawSpec": "1.1.3", + "rawSpec": "latest", "saveSpec": null, - "fetchSpec": "1.1.3" + "fetchSpec": "latest" }, "_requiredBy": [ "#USER", - "/", - "/cacache", - "/gentle-fs", - "/pacote", - "/tar" + "/" ], - "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.3.tgz", - "_shasum": "42d837d5239688d55f303003a508230fa6727142", - "_spec": "chownr@1.1.3", - "_where": "/Users/mperrotte/npminc/cli", + "_resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "_shasum": "15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece", + "_spec": "chownr@latest", + "_where": "/Users/isaacs/dev/npm/cli", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -40,8 +36,11 @@ "description": "like `chown -R`", "devDependencies": { "mkdirp": "0.3", - "rimraf": "", - "tap": "^12.0.1" + "rimraf": "^2.7.1", + "tap": "^14.10.6" + }, + "engines": { + "node": ">=10" }, "files": [ "chownr.js" @@ -55,10 +54,13 @@ "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/*.js --cov" + "test": "tap" + }, + "tap": { + "check-coverage": true }, - "version": "1.1.3" + "version": "2.0.0" } |