Initial commit
This commit is contained in:
15
node_modules/chownr/LICENSE
generated
vendored
Normal file
15
node_modules/chownr/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
88
node_modules/chownr/chownr.js
generated
vendored
Normal file
88
node_modules/chownr/chownr.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
'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)
|
||||
})
|
||||
|
||||
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)
|
||||
})
|
||||
} 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[LCHOWN](p, uid, gid, cb)
|
||||
}
|
||||
|
||||
children.forEach(child => chownrKid(p, child, uid, gid, then))
|
||||
})
|
||||
}
|
||||
|
||||
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 = readdirSync(p, { withFileTypes: true })
|
||||
} catch (er) {
|
||||
if (er && er.code === 'ENOTDIR' && er.code !== 'ENOTSUP')
|
||||
return fs[LCHOWNSYNC](p, uid, gid)
|
||||
throw er
|
||||
}
|
||||
|
||||
if (children.length)
|
||||
children.forEach(child => chownrKidSync(p, child, uid, gid))
|
||||
|
||||
return fs[LCHOWNSYNC](p, uid, gid)
|
||||
}
|
||||
|
||||
module.exports = chownr
|
||||
chownr.sync = chownrSync
|
||||
20
node_modules/chownr/package.json
generated
vendored
Normal file
20
node_modules/chownr/package.json
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
||||
"name": "chownr",
|
||||
"description": "like `chown -R`",
|
||||
"version": "1.1.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/chownr.git"
|
||||
},
|
||||
"main": "chownr.js",
|
||||
"files": [
|
||||
"chownr.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"mkdirp": "0.3",
|
||||
"rimraf": "",
|
||||
"tap": "^12.0.1"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
||||
Reference in New Issue
Block a user