first commit
This commit is contained in:
1
build/node_modules/npm-path/.npmignore
generated
vendored
Normal file
1
build/node_modules/npm-path/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
6
build/node_modules/npm-path/.travis.yml
generated
vendored
Normal file
6
build/node_modules/npm-path/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
before_install: npm install npm -g
|
||||
node_js:
|
||||
- "iojs"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
21
build/node_modules/npm-path/LICENSE
generated
vendored
Normal file
21
build/node_modules/npm-path/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.
|
||||
161
build/node_modules/npm-path/Readme.md
generated
vendored
Normal file
161
build/node_modules/npm-path/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,161 @@
|
||||
# npm-path
|
||||
|
||||
### Get a PATH containing locally installed module executables.
|
||||
|
||||
`npm-path` will get you a PATH with all of the executables available to npm scripts, without booting up all of npm(1).
|
||||
|
||||
#### `npm-path` will set your PATH to include:
|
||||
|
||||
* All of the `node_modules/.bin` directories from the current directory, up through all of its parents. This allows you to invoke the executables for any installed modules. e.g. if `mocha` is installed a dependency of the current module, then `mocha` will be available on a `npm-path` generated `$PATH`.
|
||||
* The directory containing the current `node` executable, so any scripts that invoke `node` will execute the same `node`.
|
||||
* Current npm's `node-gyp` directory, so the `node-gyp` bundled with `npm` can be used.
|
||||
|
||||
## Usage
|
||||
|
||||
### Command-line
|
||||
|
||||
```bash
|
||||
# Prints the augmented PATH to the console
|
||||
> npm-path
|
||||
# /usr/local/lib/node_modules/npm/bin/node-gyp-bin:.../node_modules/.bin:/.../usr/local/bin:/usr/local/sbin: ... etc
|
||||
```
|
||||
|
||||
Calling `npm-path` from the commandline is the equivalent of executing an npm script with the body `echo $PATH`, but without all of the overhead of booting or depending on `npm`.
|
||||
|
||||
### Set PATH
|
||||
|
||||
This will set the augmented PATH for the current process environment, or an environment you supply.
|
||||
|
||||
```js
|
||||
var npmPath = require('npm-path')
|
||||
var PATH = npmPath.PATH // get platform independent PATH key
|
||||
|
||||
npmPath(function(err, $PATH) {
|
||||
|
||||
// Note: current environment is modified!
|
||||
console.log(process.env[PATH] == $PATH) // true
|
||||
|
||||
console.log($PATH)
|
||||
// /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/.../.bin:/usr/local/bin: ...etc
|
||||
|
||||
})
|
||||
|
||||
// more explicit alternative syntax
|
||||
npmPath.set(function(err, $PATH) {
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
#### Synchronous Alternative
|
||||
|
||||
```js
|
||||
|
||||
// supplying no callback will execute method synchronously
|
||||
var $PATH = npmPath()
|
||||
console.log($PATH)
|
||||
|
||||
// more explicit alternative syntax
|
||||
$PATH = npmPath.setSync()
|
||||
```
|
||||
|
||||
#### Optional Options
|
||||
|
||||
```js
|
||||
var options = {
|
||||
env: process.env, // default.
|
||||
cwd: process.cwd() // default.
|
||||
}
|
||||
|
||||
npmPath(options, function(err, $PATH) {
|
||||
// ...
|
||||
})
|
||||
|
||||
npmPath.setSync(options)
|
||||
|
||||
// ...
|
||||
|
||||
```
|
||||
|
||||
|
||||
### Get PATH
|
||||
|
||||
This will get npm augmented PATH, but *does not modify the PATH in the environment*.
|
||||
Takes the exact same options as `set`.
|
||||
|
||||
```js
|
||||
npmPath.get(function(err, $PATH) {
|
||||
console.log($PATH)
|
||||
|
||||
// Note: current environment is NOT modified!
|
||||
console.log(process.env[PATH] == $PATH) // false
|
||||
})
|
||||
|
||||
// options is optional, takes same options as `npmPath.set`
|
||||
npmPath.get(options, function(err, $PATH) {
|
||||
console.log($PATH)
|
||||
})
|
||||
```
|
||||
|
||||
#### Synchronous Alternative
|
||||
|
||||
```js
|
||||
// supplying no callback will execute method synchronously
|
||||
var $PATH = npmPath.get()
|
||||
console.log($PATH)
|
||||
console.log(process.env[PATH] == $PATH) // false
|
||||
|
||||
// more explicit alternative syntax
|
||||
$PATH = npmPath.getSync()
|
||||
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
Both `set` and `get` take an optional options object, with optional `env` & `cwd` keys.
|
||||
|
||||
* 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)
|
||||
|
||||
There's also a `options.npm` property which you can set if you want `node-gyp` to be sourced from
|
||||
an alternative `npm` installation.
|
||||
|
||||
### Get the PATH environment variable key
|
||||
|
||||
```js
|
||||
// windows calls it's path "Path" usually, but this is not guaranteed.
|
||||
npmPath.PATH // 'Path', probably
|
||||
|
||||
// rest of the world
|
||||
npmPath.PATH // 'PATH'
|
||||
|
||||
```
|
||||
|
||||
#### Example Usage
|
||||
|
||||
```js
|
||||
process.env[npmPath.PATH] // get path environment variable
|
||||
|
||||
// set path environment variable manually
|
||||
process.env[npmPath.PATH] = npmPath.get()
|
||||
|
||||
// set path environment variable automatically
|
||||
npmPath()
|
||||
```
|
||||
|
||||
### Get the PATH separator
|
||||
|
||||
```js
|
||||
// windows
|
||||
npmPath.SEPARATOR // ';'
|
||||
|
||||
// rest of the world
|
||||
npmPath.SEPARATOR // ':'
|
||||
```
|
||||
|
||||
## Credit
|
||||
|
||||
Path lookup code adapted directly from npm.
|
||||
|
||||
# License
|
||||
|
||||
MIT
|
||||
5
build/node_modules/npm-path/bin/npm-path
generated
vendored
Executable file
5
build/node_modules/npm-path/bin/npm-path
generated
vendored
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var npmPath = require('../')
|
||||
|
||||
console.log(npmPath())
|
||||
73
build/node_modules/npm-path/find-prefix.js
generated
vendored
Normal file
73
build/node_modules/npm-path/find-prefix.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
|
||||
module.exports = function (options, cb) {
|
||||
return findPrefix(options.cwd, options.isSync, cb)
|
||||
}
|
||||
|
||||
function readdir (p, isSync, fn) {
|
||||
if (isSync) {
|
||||
try {
|
||||
var val = fs.readdirSync(p)
|
||||
} catch (err) {
|
||||
return fn(err)
|
||||
}
|
||||
|
||||
return fn(null, val)
|
||||
}
|
||||
|
||||
return fs.readdir(p, fn)
|
||||
}
|
||||
|
||||
// try to find the most reasonable prefix to use
|
||||
function findPrefix (p, isSync, cb_) {
|
||||
function cb (er, p) {
|
||||
if (isSync) return cb_(er, p)
|
||||
process.nextTick(function () {
|
||||
cb_(er, p)
|
||||
})
|
||||
}
|
||||
|
||||
p = path.resolve(p)
|
||||
// if there's no node_modules folder, then
|
||||
// walk up until we hopefully find one.
|
||||
// if none anywhere, then use cwd.
|
||||
var walkedUp = false
|
||||
while (path.basename(p) === 'node_modules') {
|
||||
p = path.dirname(p)
|
||||
walkedUp = true
|
||||
}
|
||||
if (walkedUp) return cb(null, p)
|
||||
|
||||
findPrefix_(p, p, isSync, cb)
|
||||
}
|
||||
|
||||
function findPrefix_ (p, original, isSync, cb) {
|
||||
if (p === '/' ||
|
||||
(process.platform === 'win32' && p.match(/^[a-zA-Z]:(\\|\/)?$/))) {
|
||||
return cb(null, original)
|
||||
}
|
||||
|
||||
readdir(p, isSync, function (er, files) {
|
||||
// an error right away is a bad sign.
|
||||
// unless the prefix was simply a non
|
||||
// existent directory.
|
||||
if (er && p === original) {
|
||||
if (er.code === 'ENOENT') return cb(null, original)
|
||||
return cb(er)
|
||||
}
|
||||
|
||||
// walked up too high or something.
|
||||
if (er) return cb(null, original)
|
||||
|
||||
if (files.indexOf('node_modules') !== -1 ||
|
||||
files.indexOf('package.json') !== -1) {
|
||||
return cb(null, p)
|
||||
}
|
||||
|
||||
var d = path.dirname(p)
|
||||
if (d === p) return cb(null, original)
|
||||
|
||||
return findPrefix_(d, original, isSync, cb)
|
||||
})
|
||||
}
|
||||
194
build/node_modules/npm-path/index.js
generated
vendored
Normal file
194
build/node_modules/npm-path/index.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
"use strict"
|
||||
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var which = require('which')
|
||||
var findPrefix = require('./find-prefix')
|
||||
|
||||
var PATH = getPATHKey()
|
||||
var SEPARATOR = getPATHSeparator()
|
||||
|
||||
/**
|
||||
* Get new $PATH setting with additional paths supplied by the npm.
|
||||
*
|
||||
* @param Object options Config options Object.
|
||||
* @param Object options.env Environment to use. Default: process.env
|
||||
* @param String options.wd Working directory. Default: process.cwd()
|
||||
* @param Function fn callback function.
|
||||
*/
|
||||
|
||||
function getPath(options, fn) {
|
||||
var wd = options.cwd = options.cwd || process.cwd()
|
||||
var env = options.env = options.env || process.env
|
||||
var pathArr = getPathArr(options)
|
||||
|
||||
whichNpm(options, function(err, npmPath) {
|
||||
if (err) return fn(err)
|
||||
findPrefix(options, function (err, prefixPath) {
|
||||
if (!err && prefixPath) {
|
||||
// ignore err if cannot find prefix
|
||||
pathArr.unshift(path.join(prefixPath, "node_modules", ".bin"))
|
||||
}
|
||||
// we also unshift the bundled node-gyp-bin folder so that
|
||||
// the bundled one will be used for installing things.
|
||||
pathArr.unshift(path.join(path.dirname(npmPath), "node-gyp-bin"))
|
||||
if (env[PATH]) pathArr.push(env[PATH])
|
||||
fn(null, pathArr.join(SEPARATOR))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Async wrapper around `getPath`.
|
||||
*/
|
||||
|
||||
function getPathAsync(options, fn) {
|
||||
// options is optional
|
||||
if (options instanceof Function) fn = options, options = {}
|
||||
// if no fn, execute as sync
|
||||
if (!(fn instanceof Function)) return getPathSync(options)
|
||||
options = options || {}
|
||||
options.isSync = false
|
||||
return getPath(options, fn)
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync wrapper around `getPath`.
|
||||
*/
|
||||
|
||||
function getPathSync(options) {
|
||||
options = options || {}
|
||||
options.isSync = true
|
||||
var thePath = undefined
|
||||
// sync magic: if sync true, callback is executed sync
|
||||
// therefore we can set thePath from inside it before returning
|
||||
getPath(options, function(err, foundPath) {
|
||||
if (err) throw err
|
||||
thePath = foundPath
|
||||
})
|
||||
return thePath
|
||||
}
|
||||
|
||||
/**
|
||||
* Change environment to include npm path adjustments.
|
||||
*
|
||||
* @param Object options Config options Object.
|
||||
* @param Object options.env Environment to use. Default: process.env
|
||||
* @param String options.wd Working directory. Default: process.cwd()
|
||||
* @param Function fn callback function.
|
||||
*/
|
||||
|
||||
function setPathAsync(options, fn) {
|
||||
// options is optional
|
||||
if (options instanceof Function) fn = options, options = {}
|
||||
// if no fn, execute as sync
|
||||
if (!(fn instanceof Function)) return setPathSync(options)
|
||||
|
||||
getPathAsync(options, function(err, newPath) {
|
||||
if (err) return fn(err)
|
||||
fn(null, options.env[PATH] = newPath)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync version of `setPathAsync`
|
||||
*/
|
||||
|
||||
function setPathSync(options) {
|
||||
options = options || {}
|
||||
var newPath = getPathSync(options)
|
||||
return options.env[PATH] = newPath
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate simple parts of the npm path. Basically everything that doesn't
|
||||
* depend on potentially async operations.
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
|
||||
function getPathArr(options) {
|
||||
var wd = options.cwd
|
||||
var pathArr = []
|
||||
var p = wd.split(path.sep + "node_modules" + path.sep)
|
||||
var acc = path.resolve(p.shift())
|
||||
|
||||
// first add the directory containing the `node` executable currently
|
||||
// running, so that any lifecycle script that invoke "node" will execute
|
||||
// this same one.
|
||||
pathArr.unshift(path.dirname(process.execPath))
|
||||
|
||||
p.forEach(function (pp) {
|
||||
pathArr.unshift(path.join(acc, "node_modules", ".bin"))
|
||||
acc = path.join(acc, "node_modules", pp)
|
||||
})
|
||||
pathArr.unshift(path.join(acc, "node_modules", ".bin"))
|
||||
return pathArr
|
||||
}
|
||||
|
||||
/**
|
||||
* Use callback-style signature but toggle sync execution if `isSync` is true.
|
||||
* If options.npm is supplied, this will simply provide npm/bin/npm-cli.
|
||||
*/
|
||||
|
||||
function whichNpm(options, fn) {
|
||||
var npmCli = options.npm && path.join(options.npm, 'bin', 'npm-cli.js')
|
||||
|
||||
if (options.isSync) {
|
||||
fn(null, fs.realpathSync(
|
||||
npmCli || which.sync('npm')
|
||||
))
|
||||
return
|
||||
}
|
||||
|
||||
if (options.npm) {
|
||||
process.nextTick(function() {
|
||||
fn(null, npmCli)
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
which('npm', function(err, npmPath) {
|
||||
if (err) return fn(err)
|
||||
fs.realpath(npmPath, fn)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get key to use as $PATH in environment
|
||||
*/
|
||||
|
||||
function getPATHKey() {
|
||||
var PATH = 'PATH'
|
||||
|
||||
// windows calls it's path "Path" usually, but this is not guaranteed.
|
||||
if (process.platform === "win32") {
|
||||
PATH = "Path"
|
||||
Object.keys(process.env).forEach(function (e) {
|
||||
if (e.match(/^PATH$/i)) {
|
||||
PATH = e
|
||||
}
|
||||
})
|
||||
}
|
||||
return PATH
|
||||
}
|
||||
|
||||
/**
|
||||
* Get $PATH separator based on environment
|
||||
*/
|
||||
|
||||
function getPATHSeparator() {
|
||||
return process.platform === "win32" ? ";" : ":"
|
||||
}
|
||||
|
||||
module.exports = setPathAsync
|
||||
module.exports.get = getPathAsync
|
||||
module.exports.get.sync = getPathSync
|
||||
module.exports.getSync = getPathSync
|
||||
|
||||
module.exports.set = setPathAsync
|
||||
module.exports.set.sync = setPathSync
|
||||
module.exports.setSync = setPathSync
|
||||
|
||||
module.exports.PATH = PATH
|
||||
module.exports.SEPARATOR = SEPARATOR
|
||||
65
build/node_modules/npm-path/package.json
generated
vendored
Normal file
65
build/node_modules/npm-path/package.json
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"_from": "npm-path@^1.0.0",
|
||||
"_id": "npm-path@1.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-BHSuAEGcMn1UcBt88s0F3Ii+EUA=",
|
||||
"_location": "/npm-path",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "npm-path@^1.0.0",
|
||||
"name": "npm-path",
|
||||
"escapedName": "npm-path",
|
||||
"rawSpec": "^1.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/npm-which"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/npm-path/-/npm-path-1.1.0.tgz",
|
||||
"_shasum": "0474ae00419c327d54701b7cf2cd05dc88be1140",
|
||||
"_spec": "npm-path@^1.0.0",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/npm-which",
|
||||
"author": {
|
||||
"name": "Tim Oxley"
|
||||
},
|
||||
"bin": {
|
||||
"npm-path": "bin/npm-path"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/timoxley/npm-path/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"which": "^1.2.4"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Get a PATH with all executables available to npm scripts.",
|
||||
"devDependencies": {
|
||||
"faucet": "0.0.1",
|
||||
"npm": "^3.7.2",
|
||||
"tape": "^4.4.0"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"homepage": "https://github.com/timoxley/npm-path",
|
||||
"keywords": [
|
||||
"npm",
|
||||
"run",
|
||||
"executable"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "npm-path",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/timoxley/npm-path.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "faucet"
|
||||
},
|
||||
"version": "1.1.0"
|
||||
}
|
||||
0
build/node_modules/npm-path/test/fixture/level0/test/.npmignore
generated
vendored
Normal file
0
build/node_modules/npm-path/test/fixture/level0/test/.npmignore
generated
vendored
Normal file
0
build/node_modules/npm-path/test/fixture/level0_node_modules/test/.npmignore
generated
vendored
Normal file
0
build/node_modules/npm-path/test/fixture/level0_node_modules/test/.npmignore
generated
vendored
Normal file
194
build/node_modules/npm-path/test/index.js
generated
vendored
Normal file
194
build/node_modules/npm-path/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,194 @@
|
||||
"use strict"
|
||||
|
||||
var test = require('tape')
|
||||
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var os = require('os')
|
||||
|
||||
var which = require('which')
|
||||
|
||||
var npmPath = require('../')
|
||||
|
||||
var SEP = npmPath.SEPARATOR
|
||||
var PATH = npmPath.PATH
|
||||
|
||||
var level0 = path.join(__dirname, 'fixture', '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('exports separator', function(t) {
|
||||
t.ok(npmPath.SEPARATOR)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('exports $PATH key', function(t) {
|
||||
t.ok(npmPath.PATH)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('includes current node executable dir', function(t) {
|
||||
var level0Path = npmPath.getSync({cwd: level0})
|
||||
t.ok(level0Path.indexOf(path.dirname(process.execPath) + SEP) != -1)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('async version works', function(t) {
|
||||
var isAsync = false
|
||||
npmPath.get({cwd: level0}, function(err, level0Path) {
|
||||
t.ifError(err)
|
||||
t.ok(isAsync)
|
||||
t.ok(level0Path.indexOf(path.dirname(process.execPath) + SEP) != -1)
|
||||
t.end()
|
||||
})
|
||||
isAsync = true // can only be set if above callback not synchronous
|
||||
})
|
||||
|
||||
test('no fn == sync', function(t) {
|
||||
var level0Path = npmPath.get({cwd: level0})
|
||||
t.ok(level0Path.indexOf(path.dirname(process.execPath) + SEP) != -1)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('sync options is optional', function(t) {
|
||||
var newPath = npmPath.get()
|
||||
t.ok(newPath.indexOf(path.dirname(process.execPath) + SEP) != -1)
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('async options is optional', function(t) {
|
||||
var isAsync = false
|
||||
npmPath.get(function(err, newPath) {
|
||||
t.ifError(err)
|
||||
t.ok(newPath.indexOf(path.dirname(process.execPath) + SEP) != -1)
|
||||
t.ok(isAsync)
|
||||
t.end()
|
||||
})
|
||||
isAsync = true // can only be set if above callback not synchronous
|
||||
})
|
||||
|
||||
test('includes bin from sibling dirs', function(t) {
|
||||
t.test('from existing sibling directory', function(t) {
|
||||
var level1Path = npmPath.getSync({cwd: path.join(level[0], 'test')})
|
||||
t.ok(level1Path.indexOf(binPath[0] + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level1Path.indexOf(binPath[2] + SEP) === -1, 'should not include child paths')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('from existing sibling directory async', function(t) {
|
||||
npmPath({cwd: path.join(level[0], 'test')}, function(err, level1Path) {
|
||||
t.ifError(err)
|
||||
t.ok(level1Path.indexOf(binPath[0] + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level1Path.indexOf(binPath[2] + SEP) === -1, 'should not include child paths')
|
||||
t.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('includes all .bin dirs in all parent node_modules folders', function(t) {
|
||||
t.test('no nesting', function(t) {
|
||||
var level0Path = npmPath.getSync({cwd: level[0]})
|
||||
t.ok(level0Path.indexOf(binPath[0] + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level0Path.indexOf(binPath[1] + SEP) === -1, 'should not include child paths')
|
||||
t.ok(level0Path.indexOf(binPath[2] + SEP) === -1, 'should not include child paths')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('1 level of nesting', function(t) {
|
||||
var level1Path = npmPath.getSync({cwd: level[1]})
|
||||
t.ok(level1Path.indexOf(binPath[0] + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level1Path.indexOf(binPath[1] + SEP) != -1, 'should include level 1 .bin')
|
||||
t.ok(level1Path.indexOf(binPath[2] + SEP) === -1, 'should not include child paths')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('2 levels of nesting', function(t) {
|
||||
var level1Path = npmPath.getSync({cwd: level[2]})
|
||||
t.ok(level1Path.indexOf(binPath[0] + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level1Path.indexOf(binPath[1] + SEP) != -1, 'should include level 1 .bin')
|
||||
t.ok(level1Path.indexOf(binPath[2] + SEP) != -1, 'should include level 2 .bin')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('handles directories with node_modules in the name', function(t) {
|
||||
var trickyL0 = level[0].replace('level0', 'level0_node_modules')
|
||||
var trickyL1 = level[1].replace('level0', 'level0_node_modules')
|
||||
var trickyL2 = level[2].replace('level0', 'level0_node_modules')
|
||||
|
||||
t.test('no nesting', function(t) {
|
||||
var level0Path = npmPath.getSync({cwd: trickyL0})
|
||||
t.ok(level0Path.indexOf(path.join(trickyL0, 'node_modules', '.bin') + SEP) != -1, 'should include level 0 .bin')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('1 level of nesting', function(t) {
|
||||
var level1Path = npmPath.getSync({cwd: trickyL1})
|
||||
|
||||
t.ok(level1Path.indexOf(path.join(trickyL0, 'node_modules', '.bin') + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level1Path.indexOf(path.join(trickyL1, 'node_modules', '.bin') + SEP) != -1, 'should include level 1 .bin')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.test('2 levels of nesting', function(t) {
|
||||
var level2Path = npmPath.getSync({cwd: trickyL2})
|
||||
|
||||
t.ok(level2Path.indexOf(path.join(trickyL0, 'node_modules', '.bin') + SEP) != -1, 'should include level 0 .bin')
|
||||
t.ok(level2Path.indexOf(path.join(trickyL1, 'node_modules', '.bin') + SEP) != -1, 'should include level 1 .bin')
|
||||
t.ok(level2Path.indexOf(path.join(trickyL2, 'node_modules', '.bin') + SEP) != -1, 'should include level 1 .bin')
|
||||
t.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('can set path', function(t) {
|
||||
var oldPath = process.env[PATH]
|
||||
npmPath.set.sync()
|
||||
var newPath = process.env[PATH]
|
||||
t.notDeepEqual(oldPath, newPath)
|
||||
process.env[PATH] = oldPath
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('includes node-gyp bundled with current npm', function(t) {
|
||||
var oldPath = process.env[PATH]
|
||||
var oldGypPath = which.sync('node-gyp')
|
||||
npmPath()
|
||||
var newGypPath = which.sync('node-gyp')
|
||||
t.ok(newGypPath)
|
||||
t.ok(fs.existsSync(newGypPath))
|
||||
t.ok(newGypPath.indexOf(path.join('npm', 'bin', 'node-gyp-bin') + SEP !== -1))
|
||||
process.env[PATH] = oldPath
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('can set path to npm root to use for node-gyp lookup', function(t) {
|
||||
var oldPath = process.env[PATH]
|
||||
var pathToNpm = path.resolve(
|
||||
fs.realpathSync(which.sync('npm')),
|
||||
'..',
|
||||
'..'
|
||||
)
|
||||
|
||||
var tmpFile = path.join(os.tmpdir(), 'npm-path-custom-npm')
|
||||
try {fs.unlinkSync(tmpFile)}catch(e){}
|
||||
fs.linkSync(pathToNpm, tmpFile)
|
||||
var newPath = npmPath.get({
|
||||
npm: tmpFile
|
||||
})
|
||||
t.ok(newPath.indexOf(
|
||||
path.join(tmpFile, 'bin', 'node-gyp-bin') + SEP
|
||||
) !== -1)
|
||||
process.env[PATH] = oldPath
|
||||
fs.unlinkSync(tmpFile)
|
||||
t.end()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user