first commit
This commit is contained in:
15
build/node_modules/spawn-sync/.npmignore
generated
vendored
Normal file
15
build/node_modules/spawn-sync/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
pids
|
||||
logs
|
||||
results
|
||||
npm-debug.log
|
||||
node_modules
|
||||
temp
|
||||
output.txt
|
||||
8
build/node_modules/spawn-sync/.travis.yml
generated
vendored
Normal file
8
build/node_modules/spawn-sync/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "4"
|
||||
- "5"
|
||||
os:
|
||||
- linux
|
||||
19
build/node_modules/spawn-sync/LICENSE
generated
vendored
Normal file
19
build/node_modules/spawn-sync/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Forbes Lindesay
|
||||
|
||||
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.
|
||||
53
build/node_modules/spawn-sync/README.md
generated
vendored
Normal file
53
build/node_modules/spawn-sync/README.md
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# spawn-sync
|
||||
|
||||
Polyfill for `child_process.spawnSync`.
|
||||
|
||||
On iojs and node >= 0.12 it will just export the built in `child_process.spawnSync`. On platforms that support compiling native modules it uses the [thread-sleep](https://github.com/ForbesLindesay/thread-sleep) module to wait for an output file to exist in a tight loop. In this way it gains excellent cross platform support, but don't expect it to be efficient on all platforms.
|
||||
|
||||
[](https://travis-ci.org/ForbesLindesay/spawn-sync)
|
||||
[](https://david-dm.org/ForbesLindesay/spawn-sync)
|
||||
[](https://www.npmjs.com/package/spawn-sync)
|
||||
|
||||
## Installation
|
||||
|
||||
npm install spawn-sync
|
||||
|
||||
If this fails, you can try one of the following things:
|
||||
|
||||
1. Some package managers made a stupid decision to rename the `node` executable to `nodejs` for their platform. This breaks compatibility with lots of modules. If you normally use `nodejs` instead of `node`, you should check out http://stackoverflow.com/questions/18130164/nodejs-vs-node-on-ubuntu-12-04 for possible fixes.
|
||||
|
||||
2. You can install using `--unsafe-perm`, which will fix any permissions issues.
|
||||
|
||||
npm install --unsafe-perm spawn-sync
|
||||
|
||||
3. You can install using `--ignore-scripts`, which will skip native compilation. You'll get a warning if you try to require the module, but everything should still work.
|
||||
|
||||
npm install --ignore-scripts spawn-sync
|
||||
|
||||
4. You can try [updating npm](https://docs.npmjs.com/getting-started/installing-node), since this seems to fail on some older versions of npm:
|
||||
|
||||
sudo npm install npm -g
|
||||
|
||||
5. You can upgrade to the latest version of node or iojs. This will make native compilation unnecessary. You can then use `--ignore-scripts` without getting a warning if you still have trouble.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var spawnSync = require('spawn-sync');
|
||||
|
||||
var result = spawnSync('node',
|
||||
['filename.js'],
|
||||
{input: 'write this to stdin'});
|
||||
|
||||
if (result.status !== 0) {
|
||||
process.stderr.write(result.stderr);
|
||||
process.exit(result.status);
|
||||
} else {
|
||||
process.stdout.write(result.stdout);
|
||||
process.stderr.write(result.stderr);
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
29
build/node_modules/spawn-sync/appveyor.yml
generated
vendored
Normal file
29
build/node_modules/spawn-sync/appveyor.yml
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# http://www.appveyor.com/docs/appveyor-yml
|
||||
|
||||
# Test against these versions of Node.js.
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: "0.10"
|
||||
- nodejs_version: "0.12"
|
||||
|
||||
# Install scripts. (runs after repo cloning)
|
||||
install:
|
||||
# Get the latest stable version of Node 0.STABLE.latest
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
# Typical npm stuff.
|
||||
- npm install
|
||||
|
||||
# Post-install test scripts.
|
||||
test_script:
|
||||
# Output useful info for debugging.
|
||||
- node --version
|
||||
- npm --version
|
||||
# We test multiple Windows shells
|
||||
- ps: "npm test # PowerShell" # Pass comment to PS for easier debugging
|
||||
- cmd: npm test
|
||||
|
||||
# Don't actually build using MSBuild
|
||||
build: off
|
||||
|
||||
# Set build version format here instead of in the admin panel.
|
||||
version: "{build}"
|
||||
3
build/node_modules/spawn-sync/index.js
generated
vendored
Normal file
3
build/node_modules/spawn-sync/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('child_process').spawnSync || require('./lib/spawn-sync');
|
||||
22
build/node_modules/spawn-sync/lib/json-buffer/LICENSE
generated
vendored
Normal file
22
build/node_modules/spawn-sync/lib/json-buffer/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
Copyright (c) 2013 Dominic Tarr
|
||||
|
||||
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.
|
||||
1
build/node_modules/spawn-sync/lib/json-buffer/README.md
generated
vendored
Normal file
1
build/node_modules/spawn-sync/lib/json-buffer/README.md
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Code based on https://github.com/dominictarr/json-buffer but adapted to be simpler to run in a purely node.js environment
|
||||
56
build/node_modules/spawn-sync/lib/json-buffer/index.js
generated
vendored
Normal file
56
build/node_modules/spawn-sync/lib/json-buffer/index.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
//TODO: handle reviver/dehydrate function like normal
|
||||
//and handle indentation, like normal.
|
||||
//if anyone needs this... please send pull request.
|
||||
|
||||
exports.stringify = function stringify (o) {
|
||||
if(o && Buffer.isBuffer(o))
|
||||
return JSON.stringify(':base64:' + o.toString('base64'))
|
||||
|
||||
if(o && o.toJSON)
|
||||
o = o.toJSON()
|
||||
|
||||
if(o && 'object' === typeof o) {
|
||||
var s = ''
|
||||
var array = Array.isArray(o)
|
||||
s = array ? '[' : '{'
|
||||
var first = true
|
||||
|
||||
for(var k in o) {
|
||||
var ignore = 'function' == typeof o[k] || (!array && 'undefined' === typeof o[k])
|
||||
if(Object.hasOwnProperty.call(o, k) && !ignore) {
|
||||
if(!first)
|
||||
s += ','
|
||||
first = false
|
||||
if (array) {
|
||||
s += stringify(o[k])
|
||||
} else if (o[k] !== void(0)) {
|
||||
s += stringify(k) + ':' + stringify(o[k])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s += array ? ']' : '}'
|
||||
|
||||
return s
|
||||
} else if ('string' === typeof o) {
|
||||
return JSON.stringify(/^:/.test(o) ? ':' + o : o)
|
||||
} else if ('undefined' === typeof o) {
|
||||
return 'null';
|
||||
} else
|
||||
return JSON.stringify(o)
|
||||
}
|
||||
|
||||
exports.parse = function (s) {
|
||||
return JSON.parse(s, function (key, value) {
|
||||
if('string' === typeof value) {
|
||||
if(/^:base64:/.test(value))
|
||||
return new Buffer(value.substring(8), 'base64')
|
||||
else
|
||||
return /^:/.test(value) ? value.substring(1) : value
|
||||
}
|
||||
return value
|
||||
})
|
||||
}
|
||||
89
build/node_modules/spawn-sync/lib/spawn-sync.js
generated
vendored
Normal file
89
build/node_modules/spawn-sync/lib/spawn-sync.js
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var tmpdir = require('os').tmpdir || require('os-shim').tmpdir;
|
||||
var cp = require('child_process');
|
||||
var sleep;
|
||||
var JSON = require('./json-buffer');
|
||||
try {
|
||||
sleep = require('try-thread-sleep');
|
||||
} catch (ex) {
|
||||
console.warn('Native thread-sleep not available.');
|
||||
console.warn('This will result in much slower performance, but it will still work.');
|
||||
console.warn('You should re-install spawn-sync or upgrade to the lastest version of node if possible.');
|
||||
console.warn('Check ' + path.resolve(__dirname, '../error.log') + ' for more details');
|
||||
sleep = function () {};
|
||||
}
|
||||
|
||||
var temp = path.normalize(path.join(tmpdir(), 'spawn-sync'));
|
||||
|
||||
function randomFileName(name) {
|
||||
function randomHash(count) {
|
||||
if (count === 1)
|
||||
return parseInt(16*Math.random(), 10).toString(16);
|
||||
else {
|
||||
var hash = '';
|
||||
for (var i=0; i<count; i++)
|
||||
hash += randomHash(1);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
return temp + '_' + name + '_' + String(process.pid) + randomHash(20);
|
||||
}
|
||||
function unlink(filename) {
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
} catch (ex) {
|
||||
if (ex.code !== 'ENOENT') throw ex;
|
||||
}
|
||||
}
|
||||
function tryUnlink(filename) {
|
||||
// doesn't matter too much if we fail to delete temp files
|
||||
try {
|
||||
fs.unlinkSync(filename);
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
function invoke(cmd) {
|
||||
// location to keep flag for busy waiting fallback
|
||||
var finished = randomFileName("finished");
|
||||
unlink(finished);
|
||||
if (process.platform === 'win32') {
|
||||
cmd = cmd + '& echo "finished" > ' + finished;
|
||||
} else {
|
||||
cmd = cmd + '; echo "finished" > ' + finished;
|
||||
}
|
||||
cp.exec(cmd);
|
||||
|
||||
while (!fs.existsSync(finished)) {
|
||||
// busy wait
|
||||
sleep(200);
|
||||
}
|
||||
|
||||
tryUnlink(finished);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module.exports = spawnSyncFallback;
|
||||
function spawnSyncFallback(cmd, commandArgs, options) {
|
||||
var args = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
|
||||
// node.js script to run the command
|
||||
var worker = path.normalize(__dirname + '/worker.js');
|
||||
// location to store arguments
|
||||
var input = randomFileName('input');
|
||||
var output = randomFileName('output');
|
||||
unlink(output);
|
||||
|
||||
fs.writeFileSync(input, JSON.stringify(args));
|
||||
invoke('"' + process.execPath + '" "' + worker + '" "' + input + '" "' + output + '"');
|
||||
var res = JSON.parse(fs.readFileSync(output, 'utf8'));
|
||||
tryUnlink(input);tryUnlink(output);
|
||||
return res;
|
||||
}
|
||||
56
build/node_modules/spawn-sync/lib/worker.js
generated
vendored
Normal file
56
build/node_modules/spawn-sync/lib/worker.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
var cp = require('child_process');
|
||||
var fs = require('fs');
|
||||
var concat = require('concat-stream');
|
||||
var JSON = require('./json-buffer');
|
||||
|
||||
var inputFile = process.argv[2];
|
||||
var outputFile = process.argv[3];
|
||||
|
||||
var args = JSON.parse(fs.readFileSync(inputFile, 'utf8'));
|
||||
function output(result) {
|
||||
fs.writeFileSync(outputFile, JSON.stringify(result));
|
||||
}
|
||||
|
||||
var child = cp.spawn.apply(cp, args);
|
||||
var options = (args[2] && typeof args[2] === 'object') ?
|
||||
args[2] :
|
||||
(args[1] && typeof args[1] === 'object' && !Array.isArray(args[1])) ?
|
||||
args[1] :
|
||||
{};
|
||||
|
||||
var complete = false;
|
||||
var stdout, stderr;
|
||||
child.stdout && child.stdout.pipe(concat(function (buf) {
|
||||
stdout = buf.length ? buf : new Buffer(0);
|
||||
}));
|
||||
child.stderr && child.stderr.pipe(concat(function (buf) {
|
||||
stderr = buf.length ? buf : new Buffer(0);
|
||||
}));
|
||||
child.on('error', function (err) {
|
||||
output({pid: child.pid, error: err.message});
|
||||
});
|
||||
child.on('close', function (status, signal) {
|
||||
if (options.encoding && options.encoding !== 'buffer') {
|
||||
stdout = stdout.toString(options.encoding);
|
||||
stderr = stderr.toString(options.encoding);
|
||||
}
|
||||
output({
|
||||
pid: child.pid,
|
||||
output: [null, stdout, stderr],
|
||||
stdout: stdout,
|
||||
stderr: stderr,
|
||||
status: status,
|
||||
signal: signal
|
||||
});
|
||||
});
|
||||
|
||||
if (options.timeout && typeof options.timeout === 'number') {
|
||||
setTimeout(function () {
|
||||
child.kill(options.killSignal || 'SIGTERM');
|
||||
}, options.timeout);
|
||||
}
|
||||
if (options.input && (typeof options.input === 'string' || Buffer.isBuffer(options.input))) {
|
||||
child.stdin.end(options.input);
|
||||
}
|
||||
55
build/node_modules/spawn-sync/package.json
generated
vendored
Normal file
55
build/node_modules/spawn-sync/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"_from": "spawn-sync@^1.0.6",
|
||||
"_id": "spawn-sync@1.0.15",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-sAeZVX63+wyDdsKdROih6mfldHY=",
|
||||
"_location": "/spawn-sync",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "spawn-sync@^1.0.6",
|
||||
"name": "spawn-sync",
|
||||
"escapedName": "spawn-sync",
|
||||
"rawSpec": "^1.0.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.0.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/pngout-bin/bin-check"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz",
|
||||
"_shasum": "b00799557eb7fb0c8376c29d44e8a1ea67e57476",
|
||||
"_spec": "spawn-sync@^1.0.6",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/pngout-bin/node_modules/bin-check",
|
||||
"author": {
|
||||
"name": "ForbesLindesay"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/ForbesLindesay/spawn-sync/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"concat-stream": "^1.4.7",
|
||||
"os-shim": "^0.1.2"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Prollyfill for child_process.spawnSync",
|
||||
"devDependencies": {
|
||||
"try-thread-sleep": "^1.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/ForbesLindesay/spawn-sync#readme",
|
||||
"keywords": [],
|
||||
"license": "MIT",
|
||||
"name": "spawn-sync",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ForbesLindesay/spawn-sync.git"
|
||||
},
|
||||
"scripts": {
|
||||
"postinstall": "node postinstall",
|
||||
"prepublish": "node postinstall",
|
||||
"test": "node test/index.js"
|
||||
},
|
||||
"version": "1.0.15"
|
||||
}
|
||||
42
build/node_modules/spawn-sync/postinstall.js
generated
vendored
Normal file
42
build/node_modules/spawn-sync/postinstall.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
function onError(err) {
|
||||
try {
|
||||
var str = '' + (err ? (err.stack || err.message || err) : 'null');
|
||||
require('fs').writeFileSync(__dirname + '/error.log', str);
|
||||
} catch (ex) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
var fs = require('fs');
|
||||
var cp = require('child_process');
|
||||
var REQUIRES_UPDATE = false;
|
||||
var pkg = JSON.parse(fs.readFileSync(__dirname + '/package.json', 'utf8'));
|
||||
if (cp.spawnSync || __dirname.indexOf('node_modules') === -1) {
|
||||
if(pkg.dependencies['try-thread-sleep']){
|
||||
delete pkg.dependencies['try-thread-sleep'];
|
||||
REQUIRES_UPDATE = true;
|
||||
}
|
||||
} else {
|
||||
if(!pkg.dependencies['try-thread-sleep']){
|
||||
pkg.dependencies['try-thread-sleep'] = "^1.0.0";
|
||||
REQUIRES_UPDATE = true;
|
||||
console.log('Installing native dependencies (this may take up to a minute)');
|
||||
}
|
||||
}
|
||||
if (REQUIRES_UPDATE && __dirname.indexOf('node_modules') !== -1) {
|
||||
fs.writeFileSync(__dirname + '/package.json', JSON.stringify(pkg, null, ' '));
|
||||
cp.exec((process.env.npm_execpath ? ('"' + process.argv[0] + '" "' + process.env.npm_execpath + '"') : 'npm') +
|
||||
' install --production', {
|
||||
cwd: __dirname
|
||||
}, function (err) {
|
||||
if (err) onError(err);
|
||||
process.exit(0);
|
||||
});
|
||||
setTimeout(function () {
|
||||
process.exit(0);
|
||||
}, 60000);
|
||||
}
|
||||
} catch (ex) {
|
||||
onError(ex);
|
||||
}
|
||||
91
build/node_modules/spawn-sync/test/index.js
generated
vendored
Normal file
91
build/node_modules/spawn-sync/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
var vm = require('vm');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var sleep = require('try-thread-sleep');
|
||||
|
||||
function testSpawn(spawn) {
|
||||
var result = spawn("node", [__dirname + '/test-spawn.js'], {input: 'my-output'});
|
||||
assert(result.status === 0);
|
||||
assert(Buffer.isBuffer(result.stdout));
|
||||
assert(Buffer.isBuffer(result.stderr));
|
||||
assert(result.stdout.toString() === 'output written');
|
||||
assert(result.stderr.toString() === 'error log exists');
|
||||
assert(fs.readFileSync(__dirname + '/output.txt', 'utf8') === 'my-output');
|
||||
fs.unlinkSync(__dirname + '/output.txt');
|
||||
|
||||
var result = spawn("node", [__dirname + '/test-spawn.js'], {
|
||||
input: 'my-output',
|
||||
encoding: 'utf-8'
|
||||
});
|
||||
assert(result.status === 0);
|
||||
assert(result.stdout === 'output written');
|
||||
assert(result.stderr === 'error log exists');
|
||||
assert.deepEqual(result.output, [null, 'output written', 'error log exists']);
|
||||
assert(fs.readFileSync(__dirname + '/output.txt', 'utf8') === 'my-output');
|
||||
fs.unlinkSync(__dirname + '/output.txt');
|
||||
|
||||
var result = spawn("node", [__dirname + '/test-spawn-fail.js'], {input: 'my-output'});
|
||||
assert(result.status === 13);
|
||||
assert(Buffer.isBuffer(result.stdout));
|
||||
assert(Buffer.isBuffer(result.stderr));
|
||||
assert(result.stdout.toString() === 'output written');
|
||||
assert(result.stderr.toString() === 'error log exists');
|
||||
assert(fs.readFileSync(__dirname + '/output.txt', 'utf8') === 'my-output');
|
||||
fs.unlinkSync(__dirname + '/output.txt');
|
||||
|
||||
var result = spawn("node", [__dirname + '/test-empty.js'], {input: 'my-output'});
|
||||
assert(result.status === 0);
|
||||
assert(Buffer.isBuffer(result.stdout));
|
||||
assert(Buffer.isBuffer(result.stderr));
|
||||
assert(result.stdout.toString() === '');
|
||||
assert(result.stderr.toString() === '');
|
||||
|
||||
var result = spawn("node", [__dirname + '/test-empty.js'], { stdio: ['pipe', 'ignore', 'pipe']});
|
||||
assert(result.status === 0);
|
||||
assert(Buffer.isBuffer(result.stderr));
|
||||
assert(result.stdout == null);
|
||||
assert(result.stderr.toString() === '');
|
||||
|
||||
var result = spawn("node", [__dirname + '/test-empty.js'], { stdio: ['pipe', 'pipe', 'ignore']});
|
||||
assert(result.status === 0);
|
||||
assert(Buffer.isBuffer(result.stdout));
|
||||
assert(result.stdout.toString() === '');
|
||||
assert(result.stderr == null);
|
||||
|
||||
var result = spawn("node", [__dirname + '/test-empty.js'], { stdio: ['ignore', 'pipe', 'pipe']});
|
||||
assert(result.status === 0);
|
||||
assert(Buffer.isBuffer(result.stdout));
|
||||
assert(Buffer.isBuffer(result.stderr));
|
||||
assert(result.stdout.toString() === '');
|
||||
assert(result.stderr.toString() === '');
|
||||
|
||||
// This suprisingly fails for the official API
|
||||
/*
|
||||
var start = Date.now();
|
||||
var result = spawn("node", [__dirname + '/test-spawn-timeout.js'], {timeout: 100});
|
||||
console.dir(result);
|
||||
var end = Date.now();
|
||||
assert((end - start) < 200);
|
||||
*/
|
||||
|
||||
console.log('test pass');
|
||||
}
|
||||
|
||||
if (sleep.native) {
|
||||
console.log('Using native thread-sleep');
|
||||
} else {
|
||||
console.log('Using busy waiting');
|
||||
}
|
||||
if (require('child_process').spawnSync) {
|
||||
console.log('# Test built in node API');
|
||||
testSpawn(require('child_process').spawnSync);
|
||||
} else {
|
||||
console.log('# SKIP Test built in node API');
|
||||
}
|
||||
console.log('# Test fallback operation');
|
||||
testSpawn(require('../lib/spawn-sync'));
|
||||
|
||||
console.log('All tests passed');
|
||||
0
build/node_modules/spawn-sync/test/test-empty.js
generated
vendored
Normal file
0
build/node_modules/spawn-sync/test/test-empty.js
generated
vendored
Normal file
9
build/node_modules/spawn-sync/test/test-spawn-fail.js
generated
vendored
Normal file
9
build/node_modules/spawn-sync/test/test-spawn-fail.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
process.stdin.pipe(require('fs').createWriteStream(__dirname + '/output.txt')).on('close', function () {
|
||||
setTimeout(function () {
|
||||
process.exit(13);
|
||||
}, 500);
|
||||
});
|
||||
process.stdout.write('output written');
|
||||
process.stderr.write('error log exists');
|
||||
3
build/node_modules/spawn-sync/test/test-spawn-timeout.js
generated
vendored
Normal file
3
build/node_modules/spawn-sync/test/test-spawn-timeout.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
setTimeout(function () {
|
||||
// staying alive
|
||||
}, 60000);
|
||||
5
build/node_modules/spawn-sync/test/test-spawn.js
generated
vendored
Normal file
5
build/node_modules/spawn-sync/test/test-spawn.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
process.stdin.pipe(require('fs').createWriteStream(__dirname + '/output.txt'));
|
||||
process.stdout.write('output written');
|
||||
process.stderr.write('error log exists');
|
||||
Reference in New Issue
Block a user