08-27-周三_17-09-29
This commit is contained in:
15
node_modules/win-spawn/.npmignore
generated
vendored
Normal file
15
node_modules/win-spawn/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
node_modules
|
||||
npm-debug.log
|
41
node_modules/win-spawn/README.md
generated
vendored
Normal file
41
node_modules/win-spawn/README.md
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# win-spawn
|
||||
|
||||
Spawn for node.js but in a way that works regardless of which OS you're using. Use this if you want to use spawn with a JavaScript file. It works by explicitly invoking node on windows. It also shims support for environment variable setting by attempting to parse the command with a regex. Since all modification is wrapped in `if (os === 'Windows_NT')` it can be safely used on non-windows systems and will not break anything.
|
||||
|
||||
## Installation
|
||||
|
||||
$ npm install win-spawn
|
||||
|
||||
## Usage
|
||||
|
||||
### Command Line
|
||||
|
||||
All the following will work exactly as if the 'win-spawn ' prefix was ommitted when on unix.
|
||||
|
||||
$ win-spawn foo
|
||||
$ win-spawn ./bin/foo
|
||||
$ win-spawn NODE_PATH=./lib foo
|
||||
$ win-spawn NODE_PATH=./lib foo arg1 arg2
|
||||
|
||||
You can also transform all the line endings in a directory from `\r\n` to `\n` just by running:
|
||||
|
||||
$ win-line-endings
|
||||
|
||||
You can preview the changes by running:
|
||||
|
||||
$ win-line-endings -p
|
||||
|
||||
It will ignore `node_modules` and `.git` by default, but is not clever enough to recognise binary files yet.
|
||||
|
||||
### API
|
||||
|
||||
This will just pass through to `child_process.spawn` on unix systems, but will correctly parse the arguments on windows.
|
||||
|
||||
```javascript
|
||||
spawn('foo', [], {stdio: 'inherit'});
|
||||
spawn('./bin/foo', [], {stdio: 'inherit'});
|
||||
spawn('NODE_PATH=./lib foo', [], {stdio: 'inherit'});
|
||||
spawn('NODE_PATH=./lib foo', [arg1, arg2], {stdio: 'inherit'});
|
||||
```
|
||||
|
||||

|
12
node_modules/win-spawn/bin/win-spawn
generated
vendored
Normal file
12
node_modules/win-spawn/bin/win-spawn
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var spawn = require('../index.js');
|
||||
|
||||
var args = process.argv.slice(2);
|
||||
var cmd = '';
|
||||
while (/^[A-Z_]+\=[^ \=]+$/.test(args[0])) {
|
||||
cmd += args.shift() + ' ';
|
||||
}
|
||||
cmd += args.shift();
|
||||
|
||||
spawn(cmd, args, { stdio: 'inherit' });
|
64
node_modules/win-spawn/index.js
generated
vendored
Normal file
64
node_modules/win-spawn/index.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
var cSpawn = require('child_process').spawn;
|
||||
var os = require('os').type();
|
||||
|
||||
exports = module.exports = spawn;
|
||||
function spawn(command, args, options) {
|
||||
if (os === 'Windows_NT') {
|
||||
command = command.replace(/\//g, '\\');
|
||||
|
||||
if (command === 'rm') {
|
||||
command = 'rmdir';
|
||||
if (args[0] === '-rf' || args[0] == '-fr') {
|
||||
args[0] = '/q';
|
||||
args.unshift('/s');
|
||||
}
|
||||
if (args[0] === '-f') {
|
||||
args[0] = '/q';
|
||||
}
|
||||
if (args[0] === '-r') {
|
||||
args[0] = '/s';
|
||||
}
|
||||
}
|
||||
args = args || [];
|
||||
options = options || {};
|
||||
var match, matchA;
|
||||
if (matchA = /((?:[A-Z_]+\=[^ \=]+ )+)?([^\r\n]+)/.exec(command)) {
|
||||
try {
|
||||
var file = require('fs').readFileSync(matchA[2], 'utf8');
|
||||
if (match = /\#\!\/usr\/bin\/env ([^\r\n]+)/.exec(file)) {
|
||||
args.unshift(matchA[2]);
|
||||
command = (matchA[1] || '') + match[1];
|
||||
}
|
||||
} catch (ex) { }
|
||||
}
|
||||
|
||||
if (match = /((?:[A-Z_]+\=[^ \=]+ )+)([^\r\n]+)/.exec(command)) {
|
||||
command = match[2];
|
||||
|
||||
options.env = options.env || shallowClone(process.env);
|
||||
|
||||
var env = match[1].split(' ');
|
||||
env.forEach(function (v) {
|
||||
v = v.split('=');
|
||||
if (v.length === 2) {
|
||||
options.env[v[0]] = v[1];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
args.unshift(command);
|
||||
args.unshift('/c');
|
||||
args.unshift('/d');
|
||||
command = 'cmd';
|
||||
}
|
||||
return cSpawn(command, args, options);
|
||||
}
|
||||
|
||||
function shallowClone(obj) {
|
||||
var out = {};
|
||||
Object.keys(obj)
|
||||
.forEach(function (key) {
|
||||
out[key] = obj[key];
|
||||
});
|
||||
return out;
|
||||
}
|
89
node_modules/win-spawn/package.json
generated
vendored
Normal file
89
node_modules/win-spawn/package.json
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "win-spawn",
|
||||
"raw": "win-spawn@~2.0.0",
|
||||
"rawSpec": "~2.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.0 <2.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/root/gitbook/node_modules/phantom"
|
||||
]
|
||||
],
|
||||
"_from": "win-spawn@>=2.0.0 <2.1.0",
|
||||
"_id": "win-spawn@2.0.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/win-spawn",
|
||||
"_npmUser": {
|
||||
"email": "forbes@lindesay.co.uk",
|
||||
"name": "forbeslindesay"
|
||||
},
|
||||
"_npmVersion": "1.2.10",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "win-spawn",
|
||||
"raw": "win-spawn@~2.0.0",
|
||||
"rawSpec": "~2.0.0",
|
||||
"scope": null,
|
||||
"spec": ">=2.0.0 <2.1.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/phantom"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/win-spawn/-/win-spawn-2.0.0.tgz",
|
||||
"_shasum": "397a29130ec98d0aa0bc86baa4621393effd0b07",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "win-spawn@~2.0.0",
|
||||
"_where": "/root/gitbook/node_modules/phantom",
|
||||
"author": {
|
||||
"name": "ForbesLindesay"
|
||||
},
|
||||
"bin": {
|
||||
"win-spawn": "./bin/win-spawn"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ForbesLindesay/win-spawn/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"deprecated": "use [cross-spawn](https://github.com/IndigoUnited/node-cross-spawn) or [cross-spawn-async](https://github.com/IndigoUnited/node-cross-spawn-async) instead.",
|
||||
"description": "Spawn for node.js but in a way that works regardless of which OS you're using",
|
||||
"devDependencies": {
|
||||
"linify": "~1.0.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-eL7sqd9fXWpvV9ryzGQJh713ewWntqcmcM2pj5/Tikh8AyeXkwPYd+tBT6R+Cn7IjGmJfolmrqWclpNCf4g8GQ==",
|
||||
"shasum": "397a29130ec98d0aa0bc86baa4621393effd0b07",
|
||||
"signatures": [
|
||||
{
|
||||
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
|
||||
"sig": "MEUCIQCpAqj4POXOKopJt24VV4iHCtcIqBb3ar/vYtLYKJTPnwIgI4ZI8zPf8TNGiMazmo6VSpE6mwaF/HyCXokgIboqLV8="
|
||||
}
|
||||
],
|
||||
"tarball": "https://registry.npmjs.org/win-spawn/-/win-spawn-2.0.0.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/ForbesLindesay/win-spawn#readme",
|
||||
"license": "BSD",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "forbes@lindesay.co.uk",
|
||||
"name": "forbeslindesay"
|
||||
}
|
||||
],
|
||||
"name": "win-spawn",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ForbesLindesay/win-spawn.git"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "linify transform bin"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
}
|
Reference in New Issue
Block a user