summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/chownr
diff options
context:
space:
mode:
authorKat Marchán <kzm@zkat.tech>2019-01-29 14:43:00 -0800
committerMyles Borins <mylesborins@google.com>2019-02-12 00:06:29 -0800
commit43dd49c9782848c25e5b03448c8a0f923f13c158 (patch)
treef7ac5d645019b2b844f26be66c291bbae734d097 /deps/npm/node_modules/chownr
parentb361f9577fbd72e518438d3fa0b01f7d34d814a5 (diff)
downloadandroid-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.tar.gz
android-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.tar.bz2
android-node-v8-43dd49c9782848c25e5b03448c8a0f923f13c158.zip
deps: upgrade npm to 6.7.0
PR-URL: https://github.com/nodejs/node/pull/25804 Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/npm/node_modules/chownr')
-rw-r--r--deps/npm/node_modules/chownr/chownr.js112
-rw-r--r--deps/npm/node_modules/chownr/package.json43
2 files changed, 94 insertions, 61 deletions
diff --git a/deps/npm/node_modules/chownr/chownr.js b/deps/npm/node_modules/chownr/chownr.js
index ecd7b452df..7e63928827 100644
--- a/deps/npm/node_modules/chownr/chownr.js
+++ b/deps/npm/node_modules/chownr/chownr.js
@@ -1,52 +1,88 @@
-module.exports = chownr
-chownr.sync = chownrSync
+'use strict'
+const fs = require('fs')
+const path = require('path')
+
+/* istanbul ignore next */
+const LCHOWN = fs.lchown ? 'lchown' : 'chown'
+/* istanbul ignore next */
+const LCHOWNSYNC = fs.lchownSync ? 'lchownSync' : 'chownSync'
+
+// 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)
+let readdirSync = (path, options) => fs.readdirSync(path, options)
+/* istanbul ignore next */
+if (/^v4\./.test(nodeVersion))
+ readdir = (path, options, cb) => fs.readdir(path, cb)
+
+const chownrKid = (p, child, uid, gid, cb) => {
+ if (typeof child === 'string')
+ return fs.lstat(path.resolve(p, child), (er, stats) => {
+ if (er)
+ return cb(er)
+ stats.name = child
+ chownrKid(p, stats, uid, gid, cb)
+ })
-var fs = require("fs")
-, path = require("path")
-
-function chownr (p, uid, gid, cb) {
- fs.readdir(p, function (er, children) {
- // any error other than ENOTDIR means it's not readable, or
- // doesn't exist. give up.
- if (er && er.code !== "ENOTDIR") return cb(er)
- if (er || !children.length) return fs.chown(p, uid, gid, cb)
-
- var len = children.length
- , errState = null
- children.forEach(function (child) {
- var pathChild = path.resolve(p, child);
- fs.lstat(pathChild, function(er, stats) {
- if (er)
- return cb(er)
- if (!stats.isSymbolicLink())
- chownr(pathChild, uid, gid, then)
- else
- then()
- })
+ if (child.isDirectory()) {
+ chownr(path.resolve(p, child.name), uid, gid, er => {
+ if (er)
+ return cb(er)
+ fs[LCHOWN](path.resolve(p, child.name), uid, gid, cb)
})
- function then (er) {
+ } else
+ fs[LCHOWN](path.resolve(p, child.name), uid, gid, cb)
+}
+
+
+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 || !children.length) return fs[LCHOWN](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.chown(p, uid, gid, cb)
+ if (-- len === 0) return fs[LCHOWN](p, uid, gid, cb)
}
+
+ children.forEach(child => chownrKid(p, child, uid, gid, then))
})
}
-function chownrSync (p, uid, gid) {
- var children
+const chownrKidSync = (p, child, uid, gid) => {
+ if (typeof child === 'string') {
+ const stats = fs.lstatSync(path.resolve(p, child))
+ stats.name = child
+ child = stats
+ }
+
+ if (child.isDirectory())
+ chownrSync(path.resolve(p, child.name), uid, gid)
+
+ fs[LCHOWNSYNC](path.resolve(p, child.name), uid, gid)
+}
+
+const chownrSync = (p, uid, gid) => {
+ let children
try {
- children = fs.readdirSync(p)
+ children = readdirSync(p, { withFileTypes: true })
} catch (er) {
- if (er && er.code === "ENOTDIR") return fs.chownSync(p, uid, gid)
+ if (er && er.code === 'ENOTDIR' && er.code !== 'ENOTSUP')
+ return fs[LCHOWNSYNC](p, uid, gid)
throw er
}
- if (!children.length) return fs.chownSync(p, uid, gid)
- children.forEach(function (child) {
- var pathChild = path.resolve(p, child)
- var stats = fs.lstatSync(pathChild)
- if (!stats.isSymbolicLink())
- chownrSync(pathChild, uid, gid)
- })
- return fs.chownSync(p, uid, gid)
+ if (children.length)
+ children.forEach(child => chownrKidSync(p, child, uid, gid))
+
+ return fs[LCHOWNSYNC](p, uid, gid)
}
+
+module.exports = chownr
+chownr.sync = chownrSync
diff --git a/deps/npm/node_modules/chownr/package.json b/deps/npm/node_modules/chownr/package.json
index f9a67c8243..0004fa0e1e 100644
--- a/deps/npm/node_modules/chownr/package.json
+++ b/deps/npm/node_modules/chownr/package.json
@@ -1,36 +1,28 @@
{
- "_args": [
- [
- "chownr@1.0.1",
- "/Users/rebecca/code/npm"
- ]
- ],
- "_from": "chownr@1.0.1",
- "_id": "chownr@1.0.1",
+ "_from": "chownr@1.1.1",
+ "_id": "chownr@1.1.1",
"_inBundle": false,
- "_integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=",
+ "_integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==",
"_location": "/chownr",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
- "raw": "chownr@1.0.1",
+ "raw": "chownr@1.1.1",
"name": "chownr",
"escapedName": "chownr",
- "rawSpec": "1.0.1",
+ "rawSpec": "1.1.1",
"saveSpec": null,
- "fetchSpec": "1.0.1"
+ "fetchSpec": "1.1.1"
},
"_requiredBy": [
- "/",
- "/cacache",
- "/npm-profile/cacache",
- "/npm-registry-fetch/cacache",
- "/tar"
+ "#USER",
+ "/"
],
- "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz",
- "_spec": "1.0.1",
- "_where": "/Users/rebecca/code/npm",
+ "_resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz",
+ "_shasum": "54726b8b8fff4df053c42187e801fb4412df1494",
+ "_spec": "chownr@1.1.1",
+ "_where": "/Users/aeschright/code/cli",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
@@ -39,11 +31,13 @@
"bugs": {
"url": "https://github.com/isaacs/chownr/issues"
},
+ "bundleDependencies": false,
+ "deprecated": false,
"description": "like `chown -R`",
"devDependencies": {
"mkdirp": "0.3",
"rimraf": "",
- "tap": "^1.2.0"
+ "tap": "^12.0.1"
},
"files": [
"chownr.js"
@@ -57,7 +51,10 @@
"url": "git://github.com/isaacs/chownr.git"
},
"scripts": {
- "test": "tap test/*.js"
+ "postpublish": "git push origin --all; git push origin --tags",
+ "postversion": "npm publish",
+ "preversion": "npm test",
+ "test": "tap test/*.js --cov"
},
- "version": "1.0.1"
+ "version": "1.1.1"
}