diff options
Diffstat (limited to 'node_modules/spawn-wrap/test/fixtures')
6 files changed, 47 insertions, 0 deletions
diff --git a/node_modules/spawn-wrap/test/fixtures/node_modules/npm/bin/npm-cli.js b/node_modules/spawn-wrap/test/fixtures/node_modules/npm/bin/npm-cli.js new file mode 100644 index 000000000..b3c400768 --- /dev/null +++ b/node_modules/spawn-wrap/test/fixtures/node_modules/npm/bin/npm-cli.js @@ -0,0 +1,4 @@ +'use strict'; +console.log('%j', process.execArgv) +console.log('%j', process.argv.slice(2)) +setTimeout(function () {}, 100) diff --git a/node_modules/spawn-wrap/test/fixtures/npm b/node_modules/spawn-wrap/test/fixtures/npm new file mode 100755 index 000000000..4e026deb9 --- /dev/null +++ b/node_modules/spawn-wrap/test/fixtures/npm @@ -0,0 +1,5 @@ +#!/bin/sh +// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@" +console.log('%j', process.execArgv) +console.log('%j', process.argv.slice(2)) +setTimeout(function () {}, 100) diff --git a/node_modules/spawn-wrap/test/fixtures/npm.cmd b/node_modules/spawn-wrap/test/fixtures/npm.cmd new file mode 100644 index 000000000..521ec9e4d --- /dev/null +++ b/node_modules/spawn-wrap/test/fixtures/npm.cmd @@ -0,0 +1,2 @@ +@echo This code should never be executed. +exit /B 1 diff --git a/node_modules/spawn-wrap/test/fixtures/script.js b/node_modules/spawn-wrap/test/fixtures/script.js new file mode 100755 index 000000000..3ccd0c9ea --- /dev/null +++ b/node_modules/spawn-wrap/test/fixtures/script.js @@ -0,0 +1,6 @@ +#!/usr/bin/env node +console.log('%j', process.execArgv) +console.log('%j', process.argv.slice(2)) + +// Keep the event loop alive long enough to receive signals. +setTimeout(function() {}, 100) diff --git a/node_modules/spawn-wrap/test/fixtures/test-shim.js b/node_modules/spawn-wrap/test/fixtures/test-shim.js new file mode 100644 index 000000000..b6baf69ee --- /dev/null +++ b/node_modules/spawn-wrap/test/fixtures/test-shim.js @@ -0,0 +1,3 @@ +console.log('before in shim') +require('../..').runMain() +console.log('after in shim') diff --git a/node_modules/spawn-wrap/test/fixtures/wrap.js b/node_modules/spawn-wrap/test/fixtures/wrap.js new file mode 100644 index 000000000..a8af6e471 --- /dev/null +++ b/node_modules/spawn-wrap/test/fixtures/wrap.js @@ -0,0 +1,27 @@ +#!/usr/bin/env node +var sw = require('../..') + +sw([require.resolve('./test-shim.js')]) + +var path = require('path') +var spawn = require('child_process').spawn + +spawn(path.resolve(process.argv[2]), process.argv.slice(3), { + stdio: 'inherit' +}).on('close', function (code, signal) { + if (code || signal) { + throw new Error('failed with ' + (code || signal)) + } + + // now run using PATH + process.env.PATH = path.resolve(path.dirname(process.argv[2])) + + ':' + process.env.PATH + + spawn(path.basename(process.argv[2]), process.argv.slice(3), { + stdio: 'inherit', + }, function (code, signal) { + if (code || signal) { + throw new Error('failed with ' + (code || signal)) + } + }) +}) |