diff options
author | Rebecca Turner <me@re-becca.org> | 2015-09-10 00:52:13 +0300 |
---|---|---|
committer | Rebecca Turner <me@re-becca.org> | 2015-09-10 23:47:21 +0300 |
commit | f5075513864fd50ee3f521f8306235c0dd8c2492 (patch) | |
tree | 451b6edc39abe7a8defe94cd4616cd996bb1919e /node_modules/which | |
parent | 95c40cb0abae961b63f315782000436f7d7a4936 (diff) |
which@1.1.2
Diffstat (limited to 'node_modules/which')
-rw-r--r-- | node_modules/which/.travis.yml | 8 | ||||
-rw-r--r-- | node_modules/which/package.json | 19 | ||||
-rw-r--r-- | node_modules/which/test/basic.js | 37 | ||||
-rw-r--r-- | node_modules/which/which.js | 80 |
4 files changed, 71 insertions, 73 deletions
diff --git a/node_modules/which/.travis.yml b/node_modules/which/.travis.yml new file mode 100644 index 000000000..4af02b3d1 --- /dev/null +++ b/node_modules/which/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - '0.8' + - '0.10' + - '0.12' + - 'iojs' +before_install: + - npm install -g npm@latest diff --git a/node_modules/which/package.json b/node_modules/which/package.json index 030fbd67e..af78bbeb3 100644 --- a/node_modules/which/package.json +++ b/node_modules/which/package.json @@ -6,15 +6,15 @@ ] ], "_from": "which@>=1.1.1 <1.2.0", - "_id": "which@1.1.1", + "_id": "which@1.1.2", "_inCache": true, "_location": "/which", - "_nodeVersion": "2.0.1", + "_nodeVersion": "2.5.0", "_npmUser": { "email": "isaacs@npmjs.com", "name": "isaacs" }, - "_npmVersion": "2.9.1", + "_npmVersion": "3.3.1", "_phantomChildren": {}, "_requested": { "name": "which", @@ -28,8 +28,8 @@ "/", "/node-gyp" ], - "_resolved": "https://registry.npmjs.org/which/-/which-1.1.1.tgz", - "_shasum": "9ce512459946166e12c083f08ec073380fc8cbbb", + "_resolved": "https://registry.npmjs.org/which/-/which-1.1.2.tgz", + "_shasum": "486c48af6dfecc7a7dcf9c655acf108d2dcbdf3d", "_shrinkwrap": null, "_spec": "which@~1.1.1", "_where": "/Users/rebecca/code/npm", @@ -55,11 +55,12 @@ }, "directories": {}, "dist": { - "shasum": "9ce512459946166e12c083f08ec073380fc8cbbb", - "tarball": "http://registry.npmjs.org/which/-/which-1.1.1.tgz" + "shasum": "486c48af6dfecc7a7dcf9c655acf108d2dcbdf3d", + "tarball": "http://registry.npmjs.org/which/-/which-1.1.2.tgz" }, - "gitHead": "c80a08e9f8cf7a5c0f39c2e2f87f18f153b118a8", + "gitHead": "e576e42f0c377571884f844eec58b3ca4a331681", "homepage": "https://github.com/isaacs/node-which#readme", + "installable": true, "license": "ISC", "main": "which.js", "maintainers": [ @@ -77,5 +78,5 @@ "scripts": { "test": "tap test/*.js" }, - "version": "1.1.1" + "version": "1.1.2" } diff --git a/node_modules/which/test/basic.js b/node_modules/which/test/basic.js index 189ca6d0a..80e9e96b2 100644 --- a/node_modules/which/test/basic.js +++ b/node_modules/which/test/basic.js @@ -51,31 +51,46 @@ t.test('make executable', function (t) { }) t.test('find when executable', function (t) { - t.plan(2) + t.plan(4) var opt = { pathExt: '.sh' } var expect = path.resolve(fixture, 'foo.sh').toLowerCase() + var PATH = process.env.PATH t.test('absolute', function (t) { - t.plan(2) - runTest(t) + runTest(fixture + '/foo.sh', t) + }) + + t.test('with process.env.PATH', function (t) { + process.env.PATH = fixture + runTest('foo.sh', t) + }) + + t.test('with process.env.Path', { + skip: isWindows ? false : 'Only for Windows' + }, function (t) { + process.env.PATH = "" + process.env.Path = fixture + runTest('foo.sh', t) + }) + + t.test('with path opt', function (t) { + opt.path = fixture + runTest('foo.sh', t) }) - function runTest(t) { - which(fixture + '/foo.sh', opt, function (er, found) { + function runTest(exec, t) { + t.plan(2) + which(exec, opt, function (er, found) { if (er) throw er t.equal(found.toLowerCase(), expect) + process.env.PATH = PATH }) - var found = which.sync(fixture + '/foo.sh', opt).toLowerCase() + var found = which.sync(exec, opt).toLowerCase() t.equal(found, expect) } - t.test('with path', function (t) { - t.plan(2) - opt.path = fixture - runTest(t) - }) }) t.test('clean', function (t) { diff --git a/node_modules/which/which.js b/node_modules/which/which.js index 13fc26dcf..97579de8a 100644 --- a/node_modules/which/which.js +++ b/node_modules/which/which.js @@ -11,17 +11,21 @@ var isExe var fs = require('fs') var isAbsolute = require('is-absolute') +var G = parseInt('0010', 8) +var U = parseInt('0100', 8) +var UG = parseInt('0110', 8) + if (isWindows) { // On windows, there is no good way to check that a file is executable isExe = function isExe () { return true } } else { isExe = function isExe (mod, uid, gid) { - var ret = (mod & 0001) - || (mod & 0010) && process.getgid && gid === process.getgid() - || (mod & 0100) && process.getuid && uid === process.getuid() - || (mod & 0110) && process.getuid && 0 === process.getuid() + var ret = (mod & 1) + || (mod & U) && process.getgid && gid === process.getgid() + || (mod & G) && process.getuid && uid === process.getuid() + || (mod & UG) && process.getuid && 0 === process.getuid() - if (process.getgroups && (mod & 0010)) { + if (!ret && process.getgroups && (mod & G)) { var groups = process.getgroups() for (var g = 0; g < groups.length; g++) { if (groups[g] === gid) @@ -33,27 +37,11 @@ if (isWindows) { } } -function which (cmd, opt, cb) { - if (typeof opt === 'function') { - cb = opt - opt = {} - } - +function getPathInfo(cmd, opt) { var colon = opt.colon || COLON var pathEnv = opt.path || process.env.PATH || '' var pathExt = [''] - // On windows, env.Path is common. - if (isWindows && !pathEnv) { - var k = Object.keys(process.env) - for (var p = 0; p < k.length; p++) { - if (p.toLowerCase() === 'path') { - pathEnv = process.env[p] - break - } - } - } - pathEnv = pathEnv.split(colon) if (isWindows) { @@ -68,6 +56,19 @@ function which (cmd, opt, cb) { if (isAbsolute(cmd)) pathEnv = [''] + return {env: pathEnv, ext: pathExt} +} + +function which (cmd, opt, cb) { + if (typeof opt === 'function') { + cb = opt + opt = {} + } + + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext + ;(function F (i, l) { if (i === l) return cb(new Error('not found: '+cmd)) var p = path.resolve(pathEnv[i], cmd) @@ -87,38 +88,11 @@ function which (cmd, opt, cb) { } function whichSync (cmd, opt) { - if (!opt) - opt = {} + opt = opt || {} - var colon = opt.colon || COLON - - var pathEnv = opt.path || process.env.PATH || '' - var pathExt = [''] - - // On windows, env.Path is common. - if (isWindows && !pathEnv) { - var k = Object.keys(process.env) - for (var p = 0; p < k.length; p++) { - if (p.toLowerCase() === 'path') { - pathEnv = process.env[p] - break - } - } - } - - pathEnv = pathEnv.split(colon) - - if (isWindows) { - pathEnv.unshift(process.cwd()) - pathExt = (opt.pathExt || process.env.PATHEXT || '.EXE').split(colon) - if (cmd.indexOf('.') !== -1 && pathExt[0] !== '') - pathExt.unshift('') - } - - // If it's absolute, then we don't bother searching the pathenv. - // just check the file itself, and that's it. - if (isAbsolute(cmd)) - pathEnv = [''] + var info = getPathInfo(cmd, opt) + var pathEnv = info.env + var pathExt = info.ext for (var i = 0, l = pathEnv.length; i < l; i ++) { var p = path.join(pathEnv[i], cmd) |