first commit
This commit is contained in:
1
build/node_modules/npm-which/.npmignore
generated
vendored
Normal file
1
build/node_modules/npm-which/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
21
build/node_modules/npm-which/LICENSE
generated
vendored
Normal file
21
build/node_modules/npm-which/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Tim Oxley
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
103
build/node_modules/npm-which/Readme.md
generated
vendored
Normal file
103
build/node_modules/npm-which/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
# npm-which
|
||||
|
||||
### Locate a program or locally installed node module executable
|
||||
|
||||
Use `npm-which` to locate executables which may be installed in the
|
||||
local 'node_modules/.bin', or in a parent 'node_modules/.bin' directory.
|
||||
|
||||
`npm-which` runs in the context of an npm lifecycle script with its npm-modified PATH.
|
||||
|
||||
i.e. if you install a module that has an executable script using npm install, that module's executable will be picked up by `npm-which` from anywhere in the ./node_modules tree.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
> npm install -g npm-which
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Command Line
|
||||
|
||||
```bash
|
||||
> npm-which tape
|
||||
/Users/timoxley/Projects/npm-which/node_modules/.bin/tape
|
||||
```
|
||||
|
||||
This is the equivalent of running an npm script with the body: `which tape`.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
# unless something is installed in a node_modules
|
||||
# npm-which and which(1) will have the same output:
|
||||
|
||||
> which tape
|
||||
/usr/local/bin/tape
|
||||
|
||||
> npm-which tape
|
||||
/usr/local/bin/tape
|
||||
|
||||
# install tape local to current dir
|
||||
# tape includes an executable 'tape'
|
||||
> npm install tape
|
||||
> ./node_modules/.bin/tape && echo 'found'
|
||||
found
|
||||
|
||||
# vanilla which(1) still finds global tape
|
||||
> which tape
|
||||
/usr/local/bin/tape
|
||||
|
||||
# npm-which finds locally installed tape :)
|
||||
> npm-which tape
|
||||
/Users/timoxley/Projects/npm-which/node_modules/.bin/tape
|
||||
```
|
||||
|
||||
### Programmatic
|
||||
|
||||
#### Asynchronous
|
||||
|
||||
```js
|
||||
var which = require('npm-which')
|
||||
which('tape', function(err, pathToTape) {
|
||||
if (err) return console.error(err.message)
|
||||
console.log(pathToTape) // /Users/.../node_modules/.bin/tape
|
||||
})
|
||||
```
|
||||
|
||||
#### Synchronous
|
||||
|
||||
```js
|
||||
var which = require('npm-which')
|
||||
var pathToTape = which.sync('tape')
|
||||
console.log(pathToTape) // /Users/.../node_modules/.bin/tape
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
Both async and sync versions take an optional options object:
|
||||
|
||||
* Set `options.env` if you wish to use something other than `process.env` (the default)
|
||||
* Set `options.cwd` if you wish to use something other than `process.cwd()` (the default)
|
||||
|
||||
```js
|
||||
which('tape', {cwd: '/some/other/path'}, function() {
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
## Why
|
||||
|
||||
#### npm is slow to boot
|
||||
|
||||
* Shelling out to `npm bin` is very slow; it has to wait for all of npm to boot up – this often takes longer than the actual script you want to execute!
|
||||
|
||||
#### Hard-coding paths to modules is very fragile
|
||||
|
||||
* You can't rely on './node_modules' actually containing your module! The module may exist much higher in the directory hierarchy.
|
||||
* `npm bin` returns the location of the `./node_modules/.bin` directory, but it does not take into account being called within the context of another module, also, npm slow.
|
||||
* If the module does exist in a parent directory, then './node_modules/.bin' will be missing your module's executable.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
35
build/node_modules/npm-which/bin/npm-which.js
generated
vendored
Executable file
35
build/node_modules/npm-which/bin/npm-which.js
generated
vendored
Executable file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
"use strict"
|
||||
|
||||
var program = require('commander');
|
||||
var pkg = require('../package.json')
|
||||
|
||||
var npmWhich = require('../')
|
||||
|
||||
program
|
||||
.version(pkg.version)
|
||||
.option('-c, --silent', 'No output, just return 0 if any of the executables are found, or 1 if none are found.')
|
||||
.usage('<command>')
|
||||
.parse(process.argv)
|
||||
|
||||
if (!program.args.length) return program.help()
|
||||
|
||||
var cmd = program.args[0]
|
||||
|
||||
if (program.silent) {
|
||||
try {
|
||||
npmWhich.sync(cmd)
|
||||
process.exit(0)
|
||||
} catch (e) {
|
||||
if (!e.message.match('not found:')) throw e
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
console.log(npmWhich.sync(cmd))
|
||||
} catch (e) {
|
||||
if (!e.message.match('not found:')) throw e
|
||||
console.error('%s not found', cmd)
|
||||
}
|
||||
40
build/node_modules/npm-which/index.js
generated
vendored
Normal file
40
build/node_modules/npm-which/index.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict"
|
||||
|
||||
var which = require('which')
|
||||
var npmPath = require('npm-path')
|
||||
|
||||
module.exports = function(cmd, options, fn) {
|
||||
if (options instanceof Function) fn = options, options = null
|
||||
options = options || {}
|
||||
options.cwd = options.cwd || process.cwd()
|
||||
options.env = options.env || process.env
|
||||
npmPath.get(options, function(err, newPath) {
|
||||
if (err) return fn(err)
|
||||
var oldPath = process.env[npmPath.PATH]
|
||||
process.env[npmPath.PATH] = newPath
|
||||
which(cmd, function(err, result) {
|
||||
process.env[npmPath.PATH] = oldPath
|
||||
fn(err, result)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports.sync = function(cmd, options) {
|
||||
options = options || {}
|
||||
options.cwd = options.cwd || process.cwd()
|
||||
options.env = options.env || process.env
|
||||
var err = null
|
||||
try {
|
||||
var oldPath = process.env[npmPath.PATH]
|
||||
var newPath = npmPath.getSync(options)
|
||||
process.env[npmPath.PATH] = newPath
|
||||
var result = which.sync(cmd)
|
||||
return result
|
||||
} catch(e) {
|
||||
err = e
|
||||
} finally {
|
||||
process.env[npmPath.PATH] = oldPath
|
||||
if (err) throw err
|
||||
}
|
||||
return result
|
||||
}
|
||||
67
build/node_modules/npm-which/package.json
generated
vendored
Normal file
67
build/node_modules/npm-which/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"_from": "npm-which@^1.0.1",
|
||||
"_id": "npm-which@1.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Ey0gm39zq/r9Tz9VX9EGbY2OwgI=",
|
||||
"_location": "/npm-which",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "npm-which@^1.0.1",
|
||||
"name": "npm-which",
|
||||
"escapedName": "npm-which",
|
||||
"rawSpec": "^1.0.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/npm-installed"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/npm-which/-/npm-which-1.0.2.tgz",
|
||||
"_shasum": "132d209b7f73abfafd4f3f555fd1066d8d8ec202",
|
||||
"_spec": "npm-which@^1.0.1",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/npm-installed",
|
||||
"author": {
|
||||
"name": "Tim Oxley"
|
||||
},
|
||||
"bin": {
|
||||
"npm-which": "bin/npm-which.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/timoxley/npm-which/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"commander": "^2.2.0",
|
||||
"npm-path": "^1.0.0",
|
||||
"which": "^1.0.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Locate a program or locally installed node module's executable",
|
||||
"devDependencies": {
|
||||
"faucet": "0.0.1",
|
||||
"tape": "^2.12.3"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/timoxley/npm-which",
|
||||
"keywords": [
|
||||
"npm",
|
||||
"path",
|
||||
"executable",
|
||||
"run"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "npm-which",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/timoxley/npm-which.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "faucet"
|
||||
},
|
||||
"version": "1.0.2"
|
||||
}
|
||||
60
build/node_modules/npm-which/test/index.js
generated
vendored
Normal file
60
build/node_modules/npm-which/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
"use strict"
|
||||
|
||||
var test = require('tape')
|
||||
|
||||
var path = require('path')
|
||||
|
||||
var npmWhich = require('../')
|
||||
|
||||
var level0 = path.join(__dirname, 'fixtures', 'level0')
|
||||
var level1 = path.join(level0, 'node_modules', 'level1')
|
||||
var level2 = path.join(level1, 'node_modules', 'level2')
|
||||
|
||||
var level = [level0, level1, level2]
|
||||
var binPath = level.map(function(levelPath) {
|
||||
return path.join(levelPath, "node_modules", ".bin")
|
||||
})
|
||||
|
||||
test('includes all .bin dirs in all parent node_modules folders', function(t) {
|
||||
t.test('no nesting', function(t) {
|
||||
var level1Bin = npmWhich.sync('level1', {cwd: level[0]})
|
||||
t.equal(level1Bin, path.join(binPath[0], 'level1'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('nesting', function(t) {
|
||||
var level1Bin = npmWhich.sync('level1', {cwd: level[1]})
|
||||
t.equal(level1Bin, path.join(binPath[0], 'level1'))
|
||||
var level2Bin = npmWhich.sync('level2', {cwd: level[1]})
|
||||
t.equal(level2Bin, path.join(binPath[1], 'level2'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('more nesting', function(t) {
|
||||
var level1Bin = npmWhich.sync('level1', {cwd: level[2]})
|
||||
t.equal(level1Bin, path.join(binPath[0], 'level1'))
|
||||
var level2Bin = npmWhich.sync('level2', {cwd: level[2]})
|
||||
t.equal(level2Bin, path.join(binPath[1], 'level2'))
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('does not mutate PATH', function(t) {
|
||||
var before = process.env.PATH
|
||||
var level1Bin = npmWhich.sync('level1', {env: {PATH: binPath[0]}})
|
||||
var after = process.env.PATH
|
||||
t.deepEqual(before, after)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('does not mutate PATH after failed find', function(t) {
|
||||
var before = process.env.PATH
|
||||
t.throws(function() {
|
||||
var level1Bin = npmWhich.sync('asdasd', {env: {PATH: binPath[0]}})
|
||||
})
|
||||
var after = process.env.PATH
|
||||
t.deepEqual(before, after)
|
||||
t.end()
|
||||
})
|
||||
Reference in New Issue
Block a user