mirror of https://github.com/lukechilds/node.git
Browse Source
PR-URL: https://github.com/nodejs/node/pull/14417 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Refael Ackermann <refack@gmail.com>v6.x
Rich Trott
8 years ago
committed by
Myles Borins
304 changed files with 28501 additions and 15865 deletions
File diff suppressed because it is too large
@ -0,0 +1,48 @@ |
|||||
|
/** |
||||
|
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
|
*/ |
||||
|
"use strict"; |
||||
|
|
||||
|
const espree = require("espree"); |
||||
|
const Traverser = require("../util/traverser"); |
||||
|
|
||||
|
/** |
||||
|
* Define `start`/`end` properties as throwing error. |
||||
|
* @param {ASTNode} node The node to define. |
||||
|
* @returns {void} |
||||
|
*/ |
||||
|
function defineStartEndAsError(node) { |
||||
|
Object.defineProperty(node, "start", { |
||||
|
get() { |
||||
|
throw new Error("Use node.range[0] instead of node.start"); |
||||
|
}, |
||||
|
configurable: true, |
||||
|
enumerable: false |
||||
|
}); |
||||
|
Object.defineProperty(node, "end", { |
||||
|
get() { |
||||
|
throw new Error("Use node.range[1] instead of node.end"); |
||||
|
}, |
||||
|
configurable: true, |
||||
|
enumerable: false |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* Define `start`/`end` properties of all nodes of the given AST as throwing error. |
||||
|
* @param {ASTNode} ast The root node to errorize `start`/`end` properties. |
||||
|
* @returns {void} |
||||
|
*/ |
||||
|
function defineStartEndAsErrorInTree(ast) { |
||||
|
new Traverser().traverse(ast, { enter: defineStartEndAsError }); |
||||
|
ast.tokens.forEach(defineStartEndAsError); |
||||
|
ast.comments.forEach(defineStartEndAsError); |
||||
|
} |
||||
|
|
||||
|
module.exports.parse = (code, options) => { |
||||
|
const ret = espree.parse(code, options); |
||||
|
|
||||
|
defineStartEndAsErrorInTree(ret.ast || ret); |
||||
|
|
||||
|
return ret; |
||||
|
}; |
@ -0,0 +1 @@ |
|||||
|
../acorn/bin/acorn |
@ -0,0 +1 @@ |
|||||
|
../esprima/bin/esparse.js |
@ -0,0 +1 @@ |
|||||
|
../esprima/bin/esvalidate.js |
@ -0,0 +1 @@ |
|||||
|
../js-yaml/bin/js-yaml.js |
@ -0,0 +1 @@ |
|||||
|
../mkdirp/bin/cmd.js |
@ -0,0 +1 @@ |
|||||
|
../rimraf/bin.js |
@ -0,0 +1 @@ |
|||||
|
../semver/bin/semver |
@ -0,0 +1 @@ |
|||||
|
../which/bin/which |
@ -0,0 +1 @@ |
|||||
|
../acorn/bin/acorn |
@ -0,0 +1,66 @@ |
|||||
|
{ |
||||
|
"name": "babel-code-frame", |
||||
|
"version": "6.22.0", |
||||
|
"lockfileVersion": 1, |
||||
|
"requires": true, |
||||
|
"dependencies": { |
||||
|
"ansi-regex": { |
||||
|
"version": "2.1.1", |
||||
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", |
||||
|
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" |
||||
|
}, |
||||
|
"ansi-styles": { |
||||
|
"version": "2.2.1", |
||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", |
||||
|
"integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" |
||||
|
}, |
||||
|
"chalk": { |
||||
|
"version": "1.1.3", |
||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", |
||||
|
"integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", |
||||
|
"requires": { |
||||
|
"ansi-styles": "2.2.1", |
||||
|
"escape-string-regexp": "1.0.5", |
||||
|
"has-ansi": "2.0.0", |
||||
|
"strip-ansi": "3.0.1", |
||||
|
"supports-color": "2.0.0" |
||||
|
} |
||||
|
}, |
||||
|
"escape-string-regexp": { |
||||
|
"version": "1.0.5", |
||||
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", |
||||
|
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" |
||||
|
}, |
||||
|
"esutils": { |
||||
|
"version": "2.0.2", |
||||
|
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", |
||||
|
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" |
||||
|
}, |
||||
|
"has-ansi": { |
||||
|
"version": "2.0.0", |
||||
|
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", |
||||
|
"integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", |
||||
|
"requires": { |
||||
|
"ansi-regex": "2.1.1" |
||||
|
} |
||||
|
}, |
||||
|
"js-tokens": { |
||||
|
"version": "3.0.2", |
||||
|
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", |
||||
|
"integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" |
||||
|
}, |
||||
|
"strip-ansi": { |
||||
|
"version": "3.0.1", |
||||
|
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", |
||||
|
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", |
||||
|
"requires": { |
||||
|
"ansi-regex": "2.1.1" |
||||
|
} |
||||
|
}, |
||||
|
"supports-color": { |
||||
|
"version": "2.0.0", |
||||
|
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", |
||||
|
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" |
||||
|
} |
||||
|
} |
||||
|
} |
@ -1,46 +1,98 @@ |
|||||
{ |
{ |
||||
"_from": "babel-code-frame@^6.22.0", |
"_args": [ |
||||
"_id": "babel-code-frame@6.22.0", |
[ |
||||
"_inBundle": false, |
{ |
||||
"_integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", |
"raw": "babel-code-frame@^6.22.0", |
||||
|
"scope": null, |
||||
|
"escapedName": "babel-code-frame", |
||||
|
"name": "babel-code-frame", |
||||
|
"rawSpec": "^6.22.0", |
||||
|
"spec": ">=6.22.0 <7.0.0", |
||||
|
"type": "range" |
||||
|
}, |
||||
|
"/Users/mborins/code/node/v6.x/tools/eslint-tmp/node_modules/eslint" |
||||
|
] |
||||
|
], |
||||
|
"_from": "babel-code-frame@>=6.22.0 <7.0.0", |
||||
|
"_id": "babel-code-frame@6.26.0", |
||||
|
"_inCache": true, |
||||
"_location": "/eslint/babel-code-frame", |
"_location": "/eslint/babel-code-frame", |
||||
|
"_nodeVersion": "6.9.0", |
||||
|
"_npmOperationalInternal": { |
||||
|
"host": "s3://npm-registry-packages", |
||||
|
"tmp": "tmp/babel-code-frame-6.26.0.tgz_1502898849653_0.8458143274765462" |
||||
|
}, |
||||
|
"_npmUser": { |
||||
|
"name": "hzoo", |
||||
|
"email": "hi@henryzoo.com" |
||||
|
}, |
||||
|
"_npmVersion": "4.6.1", |
||||
"_phantomChildren": {}, |
"_phantomChildren": {}, |
||||
"_requested": { |
"_requested": { |
||||
"type": "range", |
|
||||
"registry": true, |
|
||||
"raw": "babel-code-frame@^6.22.0", |
"raw": "babel-code-frame@^6.22.0", |
||||
"name": "babel-code-frame", |
"scope": null, |
||||
"escapedName": "babel-code-frame", |
"escapedName": "babel-code-frame", |
||||
|
"name": "babel-code-frame", |
||||
"rawSpec": "^6.22.0", |
"rawSpec": "^6.22.0", |
||||
"saveSpec": null, |
"spec": ">=6.22.0 <7.0.0", |
||||
"fetchSpec": "^6.22.0" |
"type": "range" |
||||
}, |
}, |
||||
"_requiredBy": [ |
"_requiredBy": [ |
||||
"/eslint" |
"/eslint" |
||||
], |
], |
||||
"_resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", |
"_resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", |
||||
"_shasum": "027620bee567a88c32561574e7fd0801d33118e4", |
"_shasum": "63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b", |
||||
|
"_shrinkwrap": null, |
||||
"_spec": "babel-code-frame@^6.22.0", |
"_spec": "babel-code-frame@^6.22.0", |
||||
"_where": "/Users/trott/io.js/tools/eslint-tmp/node_modules/eslint", |
"_where": "/Users/mborins/code/node/v6.x/tools/eslint-tmp/node_modules/eslint", |
||||
"author": { |
"author": { |
||||
"name": "Sebastian McKenzie", |
"name": "Sebastian McKenzie", |
||||
"email": "sebmck@gmail.com" |
"email": "sebmck@gmail.com" |
||||
}, |
}, |
||||
"bundleDependencies": false, |
|
||||
"dependencies": { |
"dependencies": { |
||||
"chalk": "^1.1.0", |
"chalk": "^1.1.3", |
||||
"esutils": "^2.0.2", |
"esutils": "^2.0.2", |
||||
"js-tokens": "^3.0.0" |
"js-tokens": "^3.0.2" |
||||
}, |
}, |
||||
"deprecated": false, |
|
||||
"description": "Generate errors that contain a code frame that point to source locations.", |
"description": "Generate errors that contain a code frame that point to source locations.", |
||||
|
"devDependencies": {}, |
||||
|
"directories": {}, |
||||
|
"dist": { |
||||
|
"shasum": "63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b", |
||||
|
"tarball": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz" |
||||
|
}, |
||||
"homepage": "https://babeljs.io/", |
"homepage": "https://babeljs.io/", |
||||
"license": "MIT", |
"license": "MIT", |
||||
"main": "lib/index.js", |
"main": "lib/index.js", |
||||
|
"maintainers": [ |
||||
|
{ |
||||
|
"name": "thejameskyle", |
||||
|
"email": "me@thejameskyle.com" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "sebmck", |
||||
|
"email": "sebmck@gmail.com" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "danez", |
||||
|
"email": "daniel@tschinder.de" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "hzoo", |
||||
|
"email": "hi@henryzoo.com" |
||||
|
}, |
||||
|
{ |
||||
|
"name": "loganfsmyth", |
||||
|
"email": "loganfsmyth@gmail.com" |
||||
|
} |
||||
|
], |
||||
"name": "babel-code-frame", |
"name": "babel-code-frame", |
||||
|
"optionalDependencies": {}, |
||||
|
"readme": "ERROR: No README data found!", |
||||
"repository": { |
"repository": { |
||||
"type": "git", |
"type": "git", |
||||
"url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" |
"url": "https://github.com/babel/babel/tree/master/packages/babel-code-frame" |
||||
}, |
}, |
||||
"version": "6.22.0" |
"scripts": {}, |
||||
|
"version": "6.26.0" |
||||
} |
} |
||||
|
@ -0,0 +1,19 @@ |
|||||
|
Copyright (c) 2014 IndigoUnited |
||||
|
|
||||
|
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. |
@ -0,0 +1,85 @@ |
|||||
|
# cross-spawn |
||||
|
|
||||
|
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Build status][appveyor-image]][appveyor-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] |
||||
|
|
||||
|
[npm-url]:https://npmjs.org/package/cross-spawn |
||||
|
[downloads-image]:http://img.shields.io/npm/dm/cross-spawn.svg |
||||
|
[npm-image]:http://img.shields.io/npm/v/cross-spawn.svg |
||||
|
[travis-url]:https://travis-ci.org/IndigoUnited/node-cross-spawn |
||||
|
[travis-image]:http://img.shields.io/travis/IndigoUnited/node-cross-spawn/master.svg |
||||
|
[appveyor-url]:https://ci.appveyor.com/project/satazor/node-cross-spawn |
||||
|
[appveyor-image]:https://img.shields.io/appveyor/ci/satazor/node-cross-spawn/master.svg |
||||
|
[david-dm-url]:https://david-dm.org/IndigoUnited/node-cross-spawn |
||||
|
[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-cross-spawn.svg |
||||
|
[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-cross-spawn#info=devDependencies |
||||
|
[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-cross-spawn.svg |
||||
|
|
||||
|
A cross platform solution to node's spawn and spawnSync. |
||||
|
|
||||
|
|
||||
|
## Installation |
||||
|
|
||||
|
`$ npm install cross-spawn` |
||||
|
|
||||
|
If you are using `spawnSync` on node 0.10 or older, you will also need to install `spawn-sync`: |
||||
|
|
||||
|
`$ npm install spawn-sync` |
||||
|
|
||||
|
|
||||
|
## Why |
||||
|
|
||||
|
Node has issues when using spawn on Windows: |
||||
|
|
||||
|
- It ignores [PATHEXT](https://github.com/joyent/node/issues/2318) |
||||
|
- It does not support [shebangs](http://pt.wikipedia.org/wiki/Shebang) |
||||
|
- No `options.shell` support on node < v6 |
||||
|
- It does not allow you to run `del` or `dir` |
||||
|
|
||||
|
All these issues are handled correctly by `cross-spawn`. |
||||
|
There are some known modules, such as [win-spawn](https://github.com/ForbesLindesay/win-spawn), that try to solve this but they are either broken or provide faulty escaping of shell arguments. |
||||
|
|
||||
|
|
||||
|
## Usage |
||||
|
|
||||
|
Exactly the same way as node's [`spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) or [`spawnSync`](https://nodejs.org/api/child_process.html#child_process_child_process_spawnsync_command_args_options), so it's a drop in replacement. |
||||
|
|
||||
|
|
||||
|
```js |
||||
|
var spawn = require('cross-spawn'); |
||||
|
|
||||
|
// Spawn NPM asynchronously |
||||
|
var child = spawn('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' }); |
||||
|
|
||||
|
// Spawn NPM synchronously |
||||
|
var results = spawn.sync('npm', ['list', '-g', '-depth', '0'], { stdio: 'inherit' }); |
||||
|
``` |
||||
|
|
||||
|
|
||||
|
## Caveats |
||||
|
|
||||
|
#### `options.shell` as an alternative to `cross-spawn` |
||||
|
|
||||
|
Starting from node v6, `spawn` has a `shell` option that allows you run commands from within a shell. This new option solves most of the problems that `cross-spawn` attempts to solve, but: |
||||
|
|
||||
|
- It's not supported in node < v6 |
||||
|
- It has no support for shebangs on Windows |
||||
|
- You must manually escape the command and arguments which is very error prone, specially when passing user input |
||||
|
|
||||
|
If you are using the `shell` option to spawn a command in a cross platform way, consider using `cross-spawn` instead. You have been warned. |
||||
|
|
||||
|
|
||||
|
#### Shebangs |
||||
|
|
||||
|
While `cross-spawn` handles shebangs on Windows, its support is limited: e.g.: it doesn't handle arguments after the path, e.g.: `#!/bin/bash -e`. |
||||
|
|
||||
|
Remember to always test your code on Windows! |
||||
|
|
||||
|
|
||||
|
## Tests |
||||
|
|
||||
|
`$ npm test` |
||||
|
|
||||
|
|
||||
|
## License |
||||
|
|
||||
|
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php). |
@ -0,0 +1,59 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
var cp = require('child_process'); |
||||
|
var parse = require('./lib/parse'); |
||||
|
var enoent = require('./lib/enoent'); |
||||
|
|
||||
|
var cpSpawnSync = cp.spawnSync; |
||||
|
|
||||
|
function spawn(command, args, options) { |
||||
|
var parsed; |
||||
|
var spawned; |
||||
|
|
||||
|
// Parse the arguments
|
||||
|
parsed = parse(command, args, options); |
||||
|
|
||||
|
// Spawn the child process
|
||||
|
spawned = cp.spawn(parsed.command, parsed.args, parsed.options); |
||||
|
|
||||
|
// Hook into child process "exit" event to emit an error if the command
|
||||
|
// does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
|
enoent.hookChildProcess(spawned, parsed); |
||||
|
|
||||
|
return spawned; |
||||
|
} |
||||
|
|
||||
|
function spawnSync(command, args, options) { |
||||
|
var parsed; |
||||
|
var result; |
||||
|
|
||||
|
if (!cpSpawnSync) { |
||||
|
try { |
||||
|
cpSpawnSync = require('spawn-sync'); // eslint-disable-line global-require
|
||||
|
} catch (ex) { |
||||
|
throw new Error( |
||||
|
'In order to use spawnSync on node 0.10 or older, you must ' + |
||||
|
'install spawn-sync:\n\n' + |
||||
|
' npm install spawn-sync --save' |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// Parse the arguments
|
||||
|
parsed = parse(command, args, options); |
||||
|
|
||||
|
// Spawn the child process
|
||||
|
result = cpSpawnSync(parsed.command, parsed.args, parsed.options); |
||||
|
|
||||
|
// Analyze if the command does not exists, see: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed); |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
module.exports = spawn; |
||||
|
module.exports.spawn = spawn; |
||||
|
module.exports.sync = spawnSync; |
||||
|
|
||||
|
module.exports._parse = parse; |
||||
|
module.exports._enoent = enoent; |
@ -0,0 +1,73 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
var isWin = process.platform === 'win32'; |
||||
|
var resolveCommand = require('./util/resolveCommand'); |
||||
|
|
||||
|
var isNode10 = process.version.indexOf('v0.10.') === 0; |
||||
|
|
||||
|
function notFoundError(command, syscall) { |
||||
|
var err; |
||||
|
|
||||
|
err = new Error(syscall + ' ' + command + ' ENOENT'); |
||||
|
err.code = err.errno = 'ENOENT'; |
||||
|
err.syscall = syscall + ' ' + command; |
||||
|
|
||||
|
return err; |
||||
|
} |
||||
|
|
||||
|
function hookChildProcess(cp, parsed) { |
||||
|
var originalEmit; |
||||
|
|
||||
|
if (!isWin) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
originalEmit = cp.emit; |
||||
|
cp.emit = function (name, arg1) { |
||||
|
var err; |
||||
|
|
||||
|
// If emitting "exit" event and exit code is 1, we need to check if
|
||||
|
// the command exists and emit an "error" instead
|
||||
|
// See: https://github.com/IndigoUnited/node-cross-spawn/issues/16
|
||||
|
if (name === 'exit') { |
||||
|
err = verifyENOENT(arg1, parsed, 'spawn'); |
||||
|
|
||||
|
if (err) { |
||||
|
return originalEmit.call(cp, 'error', err); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return originalEmit.apply(cp, arguments); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
function verifyENOENT(status, parsed) { |
||||
|
if (isWin && status === 1 && !parsed.file) { |
||||
|
return notFoundError(parsed.original, 'spawn'); |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
function verifyENOENTSync(status, parsed) { |
||||
|
if (isWin && status === 1 && !parsed.file) { |
||||
|
return notFoundError(parsed.original, 'spawnSync'); |
||||
|
} |
||||
|
|
||||
|
// If we are in node 10, then we are using spawn-sync; if it exited
|
||||
|
// with -1 it probably means that the command does not exist
|
||||
|
if (isNode10 && status === -1) { |
||||
|
parsed.file = isWin ? parsed.file : resolveCommand(parsed.original); |
||||
|
|
||||
|
if (!parsed.file) { |
||||
|
return notFoundError(parsed.original, 'spawnSync'); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
module.exports.hookChildProcess = hookChildProcess; |
||||
|
module.exports.verifyENOENT = verifyENOENT; |
||||
|
module.exports.verifyENOENTSync = verifyENOENTSync; |
||||
|
module.exports.notFoundError = notFoundError; |
@ -0,0 +1,113 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
var resolveCommand = require('./util/resolveCommand'); |
||||
|
var hasEmptyArgumentBug = require('./util/hasEmptyArgumentBug'); |
||||
|
var escapeArgument = require('./util/escapeArgument'); |
||||
|
var escapeCommand = require('./util/escapeCommand'); |
||||
|
var readShebang = require('./util/readShebang'); |
||||
|
|
||||
|
var isWin = process.platform === 'win32'; |
||||
|
var skipShellRegExp = /\.(?:com|exe)$/i; |
||||
|
|
||||
|
// Supported in Node >= 6 and >= 4.8
|
||||
|
var supportsShellOption = parseInt(process.version.substr(1).split('.')[0], 10) >= 6 || |
||||
|
parseInt(process.version.substr(1).split('.')[0], 10) === 4 && parseInt(process.version.substr(1).split('.')[1], 10) >= 8; |
||||
|
|
||||
|
function parseNonShell(parsed) { |
||||
|
var shebang; |
||||
|
var needsShell; |
||||
|
var applyQuotes; |
||||
|
|
||||
|
if (!isWin) { |
||||
|
return parsed; |
||||
|
} |
||||
|
|
||||
|
// Detect & add support for shebangs
|
||||
|
parsed.file = resolveCommand(parsed.command); |
||||
|
parsed.file = parsed.file || resolveCommand(parsed.command, true); |
||||
|
shebang = parsed.file && readShebang(parsed.file); |
||||
|
|
||||
|
if (shebang) { |
||||
|
parsed.args.unshift(parsed.file); |
||||
|
parsed.command = shebang; |
||||
|
needsShell = hasEmptyArgumentBug || !skipShellRegExp.test(resolveCommand(shebang) || resolveCommand(shebang, true)); |
||||
|
} else { |
||||
|
needsShell = hasEmptyArgumentBug || !skipShellRegExp.test(parsed.file); |
||||
|
} |
||||
|
|
||||
|
// If a shell is required, use cmd.exe and take care of escaping everything correctly
|
||||
|
if (needsShell) { |
||||
|
// Escape command & arguments
|
||||
|
applyQuotes = (parsed.command !== 'echo'); // Do not quote arguments for the special "echo" command
|
||||
|
parsed.command = escapeCommand(parsed.command); |
||||
|
parsed.args = parsed.args.map(function (arg) { |
||||
|
return escapeArgument(arg, applyQuotes); |
||||
|
}); |
||||
|
|
||||
|
// Make use of cmd.exe
|
||||
|
parsed.args = ['/d', '/s', '/c', '"' + parsed.command + (parsed.args.length ? ' ' + parsed.args.join(' ') : '') + '"']; |
||||
|
parsed.command = process.env.comspec || 'cmd.exe'; |
||||
|
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
||||
|
} |
||||
|
|
||||
|
return parsed; |
||||
|
} |
||||
|
|
||||
|
function parseShell(parsed) { |
||||
|
var shellCommand; |
||||
|
|
||||
|
// If node supports the shell option, there's no need to mimic its behavior
|
||||
|
if (supportsShellOption) { |
||||
|
return parsed; |
||||
|
} |
||||
|
|
||||
|
// Mimic node shell option, see: https://github.com/nodejs/node/blob/b9f6a2dc059a1062776133f3d4fd848c4da7d150/lib/child_process.js#L335
|
||||
|
shellCommand = [parsed.command].concat(parsed.args).join(' '); |
||||
|
|
||||
|
if (isWin) { |
||||
|
parsed.command = typeof parsed.options.shell === 'string' ? parsed.options.shell : process.env.comspec || 'cmd.exe'; |
||||
|
parsed.args = ['/d', '/s', '/c', '"' + shellCommand + '"']; |
||||
|
parsed.options.windowsVerbatimArguments = true; // Tell node's spawn that the arguments are already escaped
|
||||
|
} else { |
||||
|
if (typeof parsed.options.shell === 'string') { |
||||
|
parsed.command = parsed.options.shell; |
||||
|
} else if (process.platform === 'android') { |
||||
|
parsed.command = '/system/bin/sh'; |
||||
|
} else { |
||||
|
parsed.command = '/bin/sh'; |
||||
|
} |
||||
|
|
||||
|
parsed.args = ['-c', shellCommand]; |
||||
|
} |
||||
|
|
||||
|
return parsed; |
||||
|
} |
||||
|
|
||||
|
// ------------------------------------------------
|
||||
|
|
||||
|
function parse(command, args, options) { |
||||
|
var parsed; |
||||
|
|
||||
|
// Normalize arguments, similar to nodejs
|
||||
|
if (args && !Array.isArray(args)) { |
||||
|
options = args; |
||||
|
args = null; |
||||
|
} |
||||
|
|
||||
|
args = args ? args.slice(0) : []; // Clone array to avoid changing the original
|
||||
|
options = options || {}; |
||||
|
|
||||
|
// Build our parsed object
|
||||
|
parsed = { |
||||
|
command: command, |
||||
|
args: args, |
||||
|
options: options, |
||||
|
file: undefined, |
||||
|
original: command, |
||||
|
}; |
||||
|
|
||||
|
// Delegate further parsing to shell or non-shell
|
||||
|
return options.shell ? parseShell(parsed) : parseNonShell(parsed); |
||||
|
} |
||||
|
|
||||
|
module.exports = parse; |
@ -0,0 +1,30 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
function escapeArgument(arg, quote) { |
||||
|
// Convert to string
|
||||
|
arg = '' + arg; |
||||
|
|
||||
|
// If we are not going to quote the argument,
|
||||
|
// escape shell metacharacters, including double and single quotes:
|
||||
|
if (!quote) { |
||||
|
arg = arg.replace(/([()%!^<>&|;,"'\s])/g, '^$1'); |
||||
|
} else { |
||||
|
// Sequence of backslashes followed by a double quote:
|
||||
|
// double up all the backslashes and escape the double quote
|
||||
|
arg = arg.replace(/(\\*)"/g, '$1$1\\"'); |
||||
|
|
||||
|
// Sequence of backslashes followed by the end of the string
|
||||
|
// (which will become a double quote later):
|
||||
|
// double up all the backslashes
|
||||
|
arg = arg.replace(/(\\*)$/, '$1$1'); |
||||
|
|
||||
|
// All other backslashes occur literally
|
||||
|
|
||||
|
// Quote the whole thing:
|
||||
|
arg = '"' + arg + '"'; |
||||
|
} |
||||
|
|
||||
|
return arg; |
||||
|
} |
||||
|
|
||||
|
module.exports = escapeArgument; |
@ -0,0 +1,12 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
var escapeArgument = require('./escapeArgument'); |
||||
|
|
||||
|
function escapeCommand(command) { |
||||
|
// Do not escape if this command is not dangerous..
|
||||
|
// We do this so that commands like "echo" or "ifconfig" work
|
||||
|
// Quoting them, will make them unaccessible
|
||||
|
return /^[a-z0-9_-]+$/i.test(command) ? command : escapeArgument(command, true); |
||||
|
} |
||||
|
|
||||
|
module.exports = escapeCommand; |
@ -0,0 +1,18 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
// See: https://github.com/IndigoUnited/node-cross-spawn/pull/34#issuecomment-221623455
|
||||
|
function hasEmptyArgumentBug() { |
||||
|
var nodeVer; |
||||
|
|
||||
|
if (process.platform !== 'win32') { |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
nodeVer = process.version.substr(1).split('.').map(function (num) { |
||||
|
return parseInt(num, 10); |
||||
|
}); |
||||
|
|
||||
|
return (nodeVer[0] === 0 && nodeVer[1] < 12); |
||||
|
} |
||||
|
|
||||
|
module.exports = hasEmptyArgumentBug(); |
@ -0,0 +1,37 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
var fs = require('fs'); |
||||
|
var LRU = require('lru-cache'); |
||||
|
var shebangCommand = require('shebang-command'); |
||||
|
|
||||
|
var shebangCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
|
||||
|
|
||||
|
function readShebang(command) { |
||||
|
var buffer; |
||||
|
var fd; |
||||
|
var shebang; |
||||
|
|
||||
|
// Check if it is in the cache first
|
||||
|
if (shebangCache.has(command)) { |
||||
|
return shebangCache.get(command); |
||||
|
} |
||||
|
|
||||
|
// Read the first 150 bytes from the file
|
||||
|
buffer = new Buffer(150); |
||||
|
|
||||
|
try { |
||||
|
fd = fs.openSync(command, 'r'); |
||||
|
fs.readSync(fd, buffer, 0, 150, 0); |
||||
|
fs.closeSync(fd); |
||||
|
} catch (e) { /* empty */ } |
||||
|
|
||||
|
// Attempt to extract shebang (null is returned if not a shebang)
|
||||
|
shebang = shebangCommand(buffer.toString()); |
||||
|
|
||||
|
// Store the shebang in the cache
|
||||
|
shebangCache.set(command, shebang); |
||||
|
|
||||
|
return shebang; |
||||
|
} |
||||
|
|
||||
|
module.exports = readShebang; |
@ -0,0 +1,31 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
var path = require('path'); |
||||
|
var which = require('which'); |
||||
|
var LRU = require('lru-cache'); |
||||
|
|
||||
|
var commandCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec
|
||||
|
|
||||
|
function resolveCommand(command, noExtension) { |
||||
|
var resolved; |
||||
|
|
||||
|
noExtension = !!noExtension; |
||||
|
resolved = commandCache.get(command + '!' + noExtension); |
||||
|
|
||||
|
// Check if its resolved in the cache
|
||||
|
if (commandCache.has(command)) { |
||||
|
return commandCache.get(command); |
||||
|
} |
||||
|
|
||||
|
try { |
||||
|
resolved = !noExtension ? |
||||
|
which.sync(command) : |
||||
|
which.sync(command, { pathExt: path.delimiter + (process.env.PATHEXT || '') }); |
||||
|
} catch (e) { /* empty */ } |
||||
|
|
||||
|
commandCache.set(command + '!' + noExtension, resolved); |
||||
|
|
||||
|
return resolved; |
||||
|
} |
||||
|
|
||||
|
module.exports = resolveCommand; |
@ -0,0 +1,118 @@ |
|||||
|
{ |
||||
|
"_args": [ |
||||
|
[ |
||||
|
{ |
||||
|
"raw": "cross-spawn@^5.1.0", |
||||
|
"scope": null, |
||||
|
"escapedName": "cross-spawn", |
||||
|
"name": "cross-spawn", |
||||
|
"rawSpec": "^5.1.0", |
||||
|
"spec": ">=5.1.0 <6.0.0", |
||||
|
"type": "range" |
||||
|
}, |
||||
|
"/Users/mborins/code/node/v6.x/tools/eslint-tmp/node_modules/eslint" |
||||
|
] |
||||
|
], |
||||
|
"_from": "cross-spawn@>=5.1.0 <6.0.0", |
||||
|
"_id": "cross-spawn@5.1.0", |
||||
|
"_inCache": true, |
||||
|
"_location": "/eslint/cross-spawn", |
||||
|
"_nodeVersion": "7.0.0", |
||||
|
"_npmOperationalInternal": { |
||||
|
"host": "packages-12-west.internal.npmjs.com", |
||||
|
"tmp": "tmp/cross-spawn-5.1.0.tgz_1488134324770_0.025160177145153284" |
||||
|
}, |
||||
|
"_npmUser": { |
||||
|
"name": "satazor", |
||||
|
"email": "andremiguelcruz@msn.com" |
||||
|
}, |
||||
|
"_npmVersion": "3.10.8", |
||||
|
"_phantomChildren": {}, |
||||
|
"_requested": { |
||||
|
"raw": "cross-spawn@^5.1.0", |
||||
|
"scope": null, |
||||
|
"escapedName": "cross-spawn", |
||||
|
"name": "cross-spawn", |
||||
|
"rawSpec": "^5.1.0", |
||||
|
"spec": ">=5.1.0 <6.0.0", |
||||
|
"type": "range" |
||||
|
}, |
||||
|
"_requiredBy": [ |
||||
|
"/eslint" |
||||
|
], |
||||
|
"_resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", |
||||
|
"_shasum": "e8bd0efee58fcff6f8f94510a0a554bbfa235449", |
||||
|
"_shrinkwrap": null, |
||||
|
"_spec": "cross-spawn@^5.1.0", |
||||
|
"_where": "/Users/mborins/code/node/v6.x/tools/eslint-tmp/node_modules/eslint", |
||||
|
"author": { |
||||
|
"name": "IndigoUnited", |
||||
|
"email": "hello@indigounited.com", |
||||
|
"url": "http://indigounited.com" |
||||
|
}, |
||||
|
"bugs": { |
||||
|
"url": "https://github.com/IndigoUnited/node-cross-spawn/issues/" |
||||
|
}, |
||||
|
"dependencies": { |
||||
|
"lru-cache": "^4.0.1", |
||||
|
"shebang-command": "^1.2.0", |
||||
|
"which": "^1.2.9" |
||||
|
}, |
||||
|
"description": "Cross platform child_process#spawn and child_process#spawnSync", |
||||
|
"devDependencies": { |
||||
|
"@satazor/eslint-config": "^3.0.0", |
||||
|
"eslint": "^3.0.0", |
||||
|
"expect.js": "^0.3.0", |
||||
|
"glob": "^7.0.0", |
||||
|
"mkdirp": "^0.5.1", |
||||
|
"mocha": "^3.0.2", |
||||
|
"once": "^1.4.0", |
||||
|
"rimraf": "^2.5.0" |
||||
|
}, |
||||
|
"directories": {}, |
||||
|
"dist": { |
||||
|
"shasum": "e8bd0efee58fcff6f8f94510a0a554bbfa235449", |
||||
|
"tarball": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz" |
||||
|
}, |
||||
|
"files": [ |
||||
|
"index.js", |
||||
|
"lib" |
||||
|
], |
||||
|
"gitHead": "1da4c09ccf658079849a3d191b16e59bc600e8b4", |
||||
|
"homepage": "https://github.com/IndigoUnited/node-cross-spawn#readme", |
||||
|
"keywords": [ |
||||
|
"spawn", |
||||
|
"spawnSync", |
||||
|
"windows", |
||||
|
"cross", |
||||
|
"platform", |
||||
|
"path", |
||||
|
"ext", |
||||
|
"path-ext", |
||||
|
"path_ext", |
||||
|
"shebang", |
||||
|
"hashbang", |
||||
|
"cmd", |
||||
|
"execute" |
||||
|
], |
||||
|
"license": "MIT", |
||||
|
"main": "index.js", |
||||
|
"maintainers": [ |
||||
|
{ |
||||
|
"name": "satazor", |
||||
|
"email": "andremiguelcruz@msn.com" |
||||
|
} |
||||
|
], |
||||
|
"name": "cross-spawn", |
||||
|
"optionalDependencies": {}, |
||||
|
"readme": "ERROR: No README data found!", |
||||
|
"repository": { |
||||
|
"type": "git", |
||||
|
"url": "git://github.com/IndigoUnited/node-cross-spawn.git" |
||||
|
}, |
||||
|
"scripts": { |
||||
|
"lint": "eslint '{*.js,lib/**/*.js,test/**/*.js}'", |
||||
|
"test": "node test/prepare && mocha --bail test/test" |
||||
|
}, |
||||
|
"version": "5.1.0" |
||||
|
} |
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue