/compass/005_compass/compass/node_modules/cross-spawn/LICENSE |
@@ -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. |
/compass/005_compass/compass/node_modules/cross-spawn/README.md |
@@ -0,0 +1,71 @@ |
# 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) |
- It does not allow you to run `del` or `dir` |
- It does not properly escape arguments with spaces or special characters |
|
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. |
|
```javascript |
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' }); |
``` |
|
## Caveat |
|
On Windows, cross-spawn will only spawn `cmd.exe` if necessary. If the extension |
of the executable is `.exe` or `.com`, it will spawn it directly. If you wish |
to override this behavior and *always* spawn a shell, pass the `{shell: true}` |
option. |
|
|
## Tests |
|
`$ npm test` |
|
|
## License |
|
Released under the [MIT License](http://www.opensource.org/licenses/mit-license.php). |
/compass/005_compass/compass/node_modules/cross-spawn/index.js |
@@ -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; |
/compass/005_compass/compass/node_modules/cross-spawn/lib/enoent.js |
@@ -0,0 +1,73 @@ |
'use strict'; |
|
var isWin = process.platform === 'win32'; |
var resolveCommand = require('./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; |
/compass/005_compass/compass/node_modules/cross-spawn/lib/parse.js |
@@ -0,0 +1,140 @@ |
'use strict'; |
|
var fs = require('fs'); |
var LRU = require('lru-cache'); |
var resolveCommand = require('./resolveCommand'); |
var hasBrokenSpawn = require('./hasBrokenSpawn'); |
|
var isWin = process.platform === 'win32'; |
var shebangCache = new LRU({ max: 50, maxAge: 30 * 1000 }); // Cache just for 30sec |
|
function readShebang(command) { |
var buffer; |
var fd; |
var match; |
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 */ } |
|
// Check if it is a shebang |
match = buffer.toString().trim().match(/#!(.+)/i); |
|
if (match) { |
shebang = match[1].replace(/\/usr\/bin\/env\s+/i, ''); // Remove /usr/bin/env |
} |
|
// Store the shebang in the cache |
shebangCache.set(command, shebang); |
|
return shebang; |
} |
|
function escapeArg(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; |
} |
|
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 : escapeArg(command, true); |
} |
|
function requiresShell(command) { |
return !/\.(?:com|exe)$/i.test(command); |
} |
|
function parse(command, args, options) { |
var shebang; |
var applyQuotes; |
var file; |
var original; |
var shell; |
|
// 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 || {}; |
original = command; |
|
if (isWin) { |
// Detect & add support for shebangs |
file = resolveCommand(command); |
file = file || resolveCommand(command, true); |
shebang = file && readShebang(file); |
shell = options.shell || hasBrokenSpawn; |
|
if (shebang) { |
args.unshift(file); |
command = shebang; |
shell = shell || requiresShell(resolveCommand(shebang) || resolveCommand(shebang, true)); |
} else { |
shell = shell || requiresShell(file); |
} |
|
if (shell) { |
// Escape command & arguments |
applyQuotes = (command !== 'echo'); // Do not quote arguments for the special "echo" command |
command = escapeCommand(command); |
args = args.map(function (arg) { |
return escapeArg(arg, applyQuotes); |
}); |
|
// Use cmd.exe |
args = ['/s', '/c', '"' + command + (args.length ? ' ' + args.join(' ') : '') + '"']; |
command = process.env.comspec || 'cmd.exe'; |
|
// Tell node's spawn that the arguments are already escaped |
options.windowsVerbatimArguments = true; |
} |
} |
|
return { |
command: command, |
args: args, |
options: options, |
file: file, |
original: original, |
}; |
} |
|
module.exports = parse; |
/compass/005_compass/compass/node_modules/cross-spawn/lib/resolveCommand.js |
@@ -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; |
/compass/005_compass/compass/node_modules/cross-spawn/package.json |
@@ -0,0 +1,81 @@ |
{ |
"_from": "cross-spawn@^4.0.0", |
"_id": "cross-spawn@4.0.2", |
"_inBundle": false, |
"_integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=", |
"_location": "/cross-spawn", |
"_phantomChildren": {}, |
"_requested": { |
"type": "range", |
"registry": true, |
"raw": "cross-spawn@^4.0.0", |
"name": "cross-spawn", |
"escapedName": "cross-spawn", |
"rawSpec": "^4.0.0", |
"saveSpec": null, |
"fetchSpec": "^4.0.0" |
}, |
"_requiredBy": [ |
"/gm" |
], |
"_resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.2.tgz", |
"_shasum": "7b9247621c23adfdd3856004a823cbe397424d41", |
"_spec": "cross-spawn@^4.0.0", |
"_where": "/Users/horia.corcalciuc/Documents/Development/corrade-nucleus-nucleons/compass/005_compass/compass/node_modules/gm", |
"author": { |
"name": "IndigoUnited", |
"email": "hello@indigounited.com", |
"url": "http://indigounited.com" |
}, |
"bugs": { |
"url": "https://github.com/IndigoUnited/node-cross-spawn/issues/" |
}, |
"bundleDependencies": false, |
"dependencies": { |
"lru-cache": "^4.0.1", |
"which": "^1.2.9" |
}, |
"deprecated": false, |
"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", |
"rimraf": "^2.5.0" |
}, |
"files": [ |
"index.js", |
"lib" |
], |
"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", |
"name": "cross-spawn", |
"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": "4.0.2" |
} |