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:
authorRebecca Turner <me@re-becca.org>2015-05-21 08:44:47 +0300
committerRebecca Turner <me@re-becca.org>2015-05-21 08:44:47 +0300
commit01eb7f60acba584346ad8aae846657899f3b6887 (patch)
treedb6b9508affa5f14f603a20f9498adc136fe81f1 /node_modules/chownr
parent294336f0f31c7b9fe31a50075ed750db6db134d1 (diff)
chownr@0.0.2
Diffstat (limited to 'node_modules/chownr')
-rw-r--r--node_modules/chownr/LICENSE15
-rw-r--r--node_modules/chownr/package.json38
-rw-r--r--node_modules/chownr/test/basic.js85
-rw-r--r--node_modules/chownr/test/sync.js80
4 files changed, 203 insertions, 15 deletions
diff --git a/node_modules/chownr/LICENSE b/node_modules/chownr/LICENSE
new file mode 100644
index 000000000..19129e315
--- /dev/null
+++ b/node_modules/chownr/LICENSE
@@ -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.
diff --git a/node_modules/chownr/package.json b/node_modules/chownr/package.json
index bb321f8ad..a551c869e 100644
--- a/node_modules/chownr/package.json
+++ b/node_modules/chownr/package.json
@@ -6,7 +6,7 @@
},
"name": "chownr",
"description": "like `chown -R`",
- "version": "0.0.1",
+ "version": "0.0.2",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/chownr.git"
@@ -20,23 +20,31 @@
"scripts": {
"test": "tap test/*.js"
},
- "license": "BSD",
+ "license": "ISC",
+ "gitHead": "3cafeb70b2c343e893f710750406b3909ec537cb",
+ "bugs": {
+ "url": "https://github.com/isaacs/chownr/issues"
+ },
+ "homepage": "https://github.com/isaacs/chownr#readme",
+ "_id": "chownr@0.0.2",
+ "_shasum": "2f9aebf746f90808ce00607b72ba73b41604c485",
+ "_from": "chownr@0.0.2",
+ "_npmVersion": "2.10.0",
+ "_nodeVersion": "2.0.1",
"_npmUser": {
"name": "isaacs",
- "email": "i@izs.me"
- },
- "_id": "chownr@0.0.1",
- "dependencies": {},
- "optionalDependencies": {},
- "engines": {
- "node": "*"
+ "email": "isaacs@npmjs.com"
},
- "_engineSupported": true,
- "_npmVersion": "1.1.23",
- "_nodeVersion": "v0.7.10-pre",
- "_defaultsLoaded": true,
"dist": {
- "shasum": "51d18189d9092d5f8afd623f3288bfd1c6bf1a62"
+ "shasum": "2f9aebf746f90808ce00607b72ba73b41604c485",
+ "tarball": "http://registry.npmjs.org/chownr/-/chownr-0.0.2.tgz"
},
- "_from": "../chownr"
+ "maintainers": [
+ {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ }
+ ],
+ "directories": {},
+ "_resolved": "https://registry.npmjs.org/chownr/-/chownr-0.0.2.tgz"
}
diff --git a/node_modules/chownr/test/basic.js b/node_modules/chownr/test/basic.js
new file mode 100644
index 000000000..e76fb5efc
--- /dev/null
+++ b/node_modules/chownr/test/basic.js
@@ -0,0 +1,85 @@
+if (!process.getuid || !process.getgid) {
+ throw new Error("Tests require getuid/getgid support")
+}
+
+var curUid = +process.getuid()
+, curGid = +process.getgid()
+, chownr = require("../")
+, test = require("tap").test
+, mkdirp = require("mkdirp")
+, rimraf = require("rimraf")
+, fs = require("fs")
+
+// sniff the 'id' command for other groups that i can legally assign to
+var exec = require("child_process").exec
+, groups
+, dirs = []
+
+exec("id", function (code, output) {
+ if (code) throw new Error("failed to run 'id' command")
+ groups = output.trim().split("groups=")[1].split(",").map(function (s) {
+ return parseInt(s, 10)
+ }).filter(function (g) {
+ return g !== curGid
+ })
+
+ console.error([curUid, groups[0]], "uid, gid")
+
+ rimraf("/tmp/chownr", function (er) {
+ if (er) throw er
+ var cnt = 5
+ for (var i = 0; i < 5; i ++) {
+ mkdirp(getDir(), then)
+ }
+ function then (er) {
+ if (er) throw er
+ if (-- cnt === 0) {
+ runTest()
+ }
+ }
+ })
+})
+
+function getDir () {
+ var dir = "/tmp/chownr"
+
+ dir += "/" + Math.floor(Math.random() * Math.pow(16,4)).toString(16)
+ dirs.push(dir)
+ dir += "/" + Math.floor(Math.random() * Math.pow(16,4)).toString(16)
+ dirs.push(dir)
+ dir += "/" + Math.floor(Math.random() * Math.pow(16,4)).toString(16)
+ dirs.push(dir)
+ return dir
+}
+
+function runTest () {
+ test("should complete successfully", function (t) {
+ console.error("calling chownr", curUid, groups[0], typeof curUid, typeof groups[0])
+ chownr("/tmp/chownr", curUid, groups[0], function (er) {
+ t.ifError(er)
+ t.end()
+ })
+ })
+
+ dirs.forEach(function (dir) {
+ test("verify "+dir, function (t) {
+ fs.stat(dir, function (er, st) {
+ if (er) {
+ t.ifError(er)
+ return t.end()
+ }
+ t.equal(st.uid, curUid, "uid should be " + curUid)
+ t.equal(st.gid, groups[0], "gid should be "+groups[0])
+ t.end()
+ })
+ })
+ })
+
+ test("cleanup", function (t) {
+ rimraf("/tmp/chownr/", function (er) {
+ t.ifError(er)
+ t.end()
+ })
+ })
+}
+
diff --git a/node_modules/chownr/test/sync.js b/node_modules/chownr/test/sync.js
new file mode 100644
index 000000000..81d554b3c
--- /dev/null
+++ b/node_modules/chownr/test/sync.js
@@ -0,0 +1,80 @@
+if (!process.getuid || !process.getgid) {
+ throw new Error("Tests require getuid/getgid support")
+}
+
+var curUid = +process.getuid()
+, curGid = +process.getgid()
+, chownr = require("../")
+, test = require("tap").test
+, mkdirp = require("mkdirp")
+, rimraf = require("rimraf")
+, fs = require("fs")
+
+// sniff the 'id' command for other groups that i can legally assign to
+var exec = require("child_process").exec
+, groups
+, dirs = []
+
+exec("id", function (code, output) {
+ if (code) throw new Error("failed to run 'id' command")
+ groups = output.trim().split("groups=")[1].split(",").map(function (s) {
+ return parseInt(s, 10)
+ }).filter(function (g) {
+ return g !== curGid
+ })
+
+ console.error([curUid, groups[0]], "uid, gid")
+
+ rimraf("/tmp/chownr", function (er) {
+ if (er) throw er
+ var cnt = 5
+ for (var i = 0; i < 5; i ++) {
+ mkdirp(getDir(), then)
+ }
+ function then (er) {
+ if (er) throw er
+ if (-- cnt === 0) {
+ runTest()
+ }
+ }
+ })
+})
+
+function getDir () {
+ var x = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
+ var y = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
+ var z = Math.floor(Math.random() * Math.pow(16,4)).toString(16);
+ var dir = "/tmp/chownr/" + [x,y,z].join("/")
+ dirs.push(dir)
+ return dir
+}
+
+function runTest () {
+ test("should complete successfully", function (t) {
+ console.error("calling chownr", curUid, groups[0], typeof curUid, typeof groups[0])
+ chownr.sync("/tmp/chownr", curUid, groups[0])
+ t.end()
+ })
+
+ dirs.forEach(function (dir) {
+ test("verify "+dir, function (t) {
+ fs.stat(dir, function (er, st) {
+ if (er) {
+ t.ifError(er)
+ return t.end()
+ }
+ t.equal(st.uid, curUid, "uid should be " + curUid)
+ t.equal(st.gid, groups[0], "gid should be "+groups[0])
+ t.end()
+ })
+ })
+ })
+
+ test("cleanup", function (t) {
+ rimraf("/tmp/chownr/", function (er) {
+ t.ifError(er)
+ t.end()
+ })
+ })
+}
+