Current Dev State

This commit is contained in:
Tim Lorsbach
2025-06-23 20:13:54 +02:00
parent b4f9bb277d
commit ded50edaa2
22617 changed files with 4345095 additions and 174 deletions

View File

@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

View File

@ -0,0 +1,97 @@
# spawn-wrap
Wrap all spawned Node.js child processes by adding environs and
arguments ahead of the main JavaScript file argument.
Any child processes launched by that child process will also be
wrapped in a similar fashion.
This is a bit of a brutal hack, designed primarily to support code
coverage reporting in cases where tests or the system under test are
loaded via child processes rather than via `require()`.
It can also be handy if you want to run your own mock executable
instead of some other thing when child procs call into it.
[![Build Status](https://travis-ci.org/tapjs/spawn-wrap.svg)](https://travis-ci.org/tapjs/spawn-wrap) [![Build status](https://ci.appveyor.com/api/projects/status/oea7gdvqa0qeijrm?svg=true)](https://ci.appveyor.com/project/isaacs/spawn-wrap)
## USAGE
```javascript
var wrap = require('spawn-wrap')
// wrap(wrapperArgs, environs)
var unwrap = wrap(['/path/to/my/main.js', 'foo=bar'], { FOO: 1 })
// later to undo the wrapping, you can call the returned function
unwrap()
```
In this example, the `/path/to/my/main.js` file will be used as the
"main" module, whenever any Node or io.js child process is started,
whether via a call to `spawn` or `exec`, whether node is invoked
directly as the command or as the result of a shebang `#!` lookup.
In `/path/to/my/main.js`, you can do whatever instrumentation or
environment manipulation you like. When you're done, and ready to run
the "real" main.js file (ie, the one that was spawned in the first
place), you can do this:
```javascript
// /path/to/my/main.js
// process.argv[1] === 'foo=bar'
// and process.env.FOO === '1'
// my wrapping manipulations
setupInstrumentationOrCoverageOrWhatever()
process.on('exit', function (code) {
storeCoverageInfoSynchronously()
})
// now run the instrumented and covered or whatever codes
require('spawn-wrap').runMain()
```
## CONTRACTS and CAVEATS
The initial wrap call uses synchronous I/O. Probably you should not
be using this script in any production environments anyway.
Also, this will slow down child process execution by a lot, since
we're adding a few layers of indirection.
The contract which this library aims to uphold is:
* Wrapped processes behave identical to their unwrapped counterparts
for all intents and purposes. That means that the wrapper script
propagates all signals and exit codes.
* If you send a signal to the wrapper, the child gets the signal.
* If the child exits with a numeric status code, then the wrapper
exits with that code.
* If the child dies with a signal, then the wrapper dies with the
same signal.
* If you execute any Node child process, in any of the various ways
that such a thing can be done, it will be wrapped.
* Children of wrapped processes are also wrapped.
(Much of this made possible by
[foreground-child](http://npm.im/foreground-child).)
There are a few ways situations in which this contract cannot be
adhered to, despite best efforts:
1. In order to handle cases where `node` is invoked in a shell script,
the `PATH` environment variable is modified such that the the shim
will be run before the "real" node. However, since Windows does
not allow executing shebang scripts like regular programs, a
`node.cmd` file is required.
2. Signal propagation through `dash` doesn't always work. So, if you
use `child_process.exec()` on systems where `/bin/sh` is actually
`dash`, then the process may exit with a status code > 128 rather
than indicating that it received a signal.
3. `cmd.exe` is even stranger with how it propagates and interprets
unix signals. If you want your programs to be portable, then
probably you wanna not rely on signals too much.
4. It *is* possible to escape the wrapping, if you spawn a bash
script, and that script modifies the `PATH`, and then calls a
specific `node` binary explicitly.

View File

@ -0,0 +1,438 @@
module.exports = wrap
wrap.runMain = runMain
var Module = require('module')
var fs = require('fs')
var cp = require('child_process')
var ChildProcess = cp.ChildProcess
var assert = require('assert')
var crypto = require('crypto')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var path = require('path')
var signalExit = require('signal-exit')
var homedir = require('os-homedir')() + '/.node-spawn-wrap-'
var which = require('which')
var util = require('util')
var doDebug = process.env.SPAWN_WRAP_DEBUG === '1'
var debug = doDebug ? function () {
var message = util.format.apply(util, arguments).trim()
var pref = 'SW ' + process.pid + ': '
message = pref + message.split('\n').join('\n' + pref)
process.stderr.write(message + '\n')
} : function () {}
var shim = '#!' + process.execPath + '\n' +
fs.readFileSync(__dirname + '/shim.js')
var isWindows = require('./lib/is-windows')()
var pathRe = /^PATH=/
if (isWindows) pathRe = /^PATH=/i
var colon = isWindows ? ';' : ':'
function wrap (argv, env, workingDir) {
if (!ChildProcess) {
var child = cp.spawn(process.execPath, [])
ChildProcess = child.constructor
child.kill('SIGKILL')
}
// spawn_sync available since Node v0.11
var spawnSyncBinding, spawnSync
try {
spawnSyncBinding = process.binding('spawn_sync')
} catch (e) {}
// if we're passed in the working dir, then it means that setup
// was already done, so no need.
var doSetup = !workingDir
if (doSetup) {
workingDir = setup(argv, env)
}
var spawn = ChildProcess.prototype.spawn
if (spawnSyncBinding) {
spawnSync = spawnSyncBinding.spawn
}
function unwrap () {
if (doSetup && !doDebug) {
rimraf.sync(workingDir)
}
ChildProcess.prototype.spawn = spawn
if (spawnSyncBinding) {
spawnSyncBinding.spawn = spawnSync
}
}
if (spawnSyncBinding) {
spawnSyncBinding.spawn = wrappedSpawnFunction(spawnSync, workingDir)
}
ChildProcess.prototype.spawn = wrappedSpawnFunction(spawn, workingDir)
return unwrap
}
function wrappedSpawnFunction (fn, workingDir) {
return wrappedSpawn
function wrappedSpawn (options) {
munge(workingDir, options)
debug('WRAPPED', options)
return fn.call(this, options)
}
}
function isSh (file) {
return file === 'dash' ||
file === 'sh' ||
file === 'bash' ||
file === 'zsh'
}
function mungeSh (workingDir, options) {
var cmdi = options.args.indexOf('-c')
if (cmdi === -1)
return // no -c argument
var c = options.args[cmdi + 1]
var re = /^\s*((?:[^\= ]*\=[^\=\s]*)*[\s]*)([^\s]+|"[^"]+"|'[^']+')( .*)?$/
var match = c.match(re)
if (!match)
return // not a command invocation. weird but possible
var command = match[2]
// strip quotes off the command
var quote = command.charAt(0)
if ((quote === '"' || quote === '\'') && quote === command.slice(-1)) {
command = command.slice(1, -1)
}
var exe = path.basename(command)
if (isNode(exe)) {
options.originalNode = command
c = match[1] + match[2] + ' "' + workingDir + '/node" ' + match[3]
options.args[cmdi + 1] = c
} else if (exe === 'npm' && !isWindows) {
// XXX this will exhibit weird behavior when using /path/to/npm,
// if some other npm is first in the path.
var npmPath = whichOrUndefined('npm')
if (npmPath) {
c = c.replace(re, '$1 "' + workingDir + '/node" "' + npmPath + '" $3')
options.args[cmdi + 1] = c
debug('npm munge!', c)
}
}
}
function isCmd (file) {
var comspec = path.basename(process.env.comspec || '').replace(/\.exe$/i, '')
return isWindows && (file === comspec || /^cmd(\.exe|\.EXE)?$/.test(file))
}
function mungeCmd (workingDir, options) {
var cmdi = options.args.indexOf('/c')
if (cmdi === -1)
return
var re = /^\s*("*)([^"]*?\b(?:node|iojs)(?:\.exe|\.EXE)?)("*)( .*)?$/
var npmre = /^\s*("*)([^"]*?\b(?:npm))("*)( |$)/
var path_ = require('path')
if (path_.win32)
path_ = path_.win32
var command = options.args[cmdi + 1]
if (!command)
return
var m = command.match(re)
var replace
if (m) {
options.originalNode = m[2]
replace = m[1] + workingDir + '/node.cmd' + m[3] + m[4]
options.args[cmdi + 1] = m[1] + m[2] + m[3] +
' "' + workingDir + '\\node"' + m[4]
} else {
// XXX probably not a good idea to rewrite to the first npm in the
// path if it's a full path to npm. And if it's not a full path to
// npm, then the dirname will not work properly!
m = command.match(npmre)
if (!m)
return
var npmPath = whichOrUndefined('npm') || 'npm'
npmPath = path_.dirname(npmPath) + '\\node_modules\\npm\\bin\\npm-cli.js'
replace = m[1] + workingDir + '/node.cmd' +
' "' + npmPath + '"' +
m[3] + m[4]
options.args[cmdi + 1] = command.replace(npmre, replace)
}
}
function isNode (file) {
var cmdname = path.basename(process.execPath).replace(/\.exe$/i, '')
return file === 'node' || file === 'iojs' || cmdname === file
}
function mungeNode (workingDir, options) {
options.originalNode = options.file
var command = path.basename(options.file).replace(/\.exe$/i, '')
// make sure it has a main script.
// otherwise, just let it through.
var a = 0
var hasMain = false
var mainIndex = 1
for (var a = 1; !hasMain && a < options.args.length; a++) {
switch (options.args[a]) {
case '-p':
case '-i':
case '--interactive':
case '--eval':
case '-e':
case '-pe':
hasMain = false
a = options.args.length
continue
case '-r':
case '--require':
a += 1
continue
default:
if (options.args[a].match(/^-/)) {
continue
} else {
hasMain = true
mainIndex = a
a = options.args.length
break
}
}
}
if (hasMain) {
var replace = workingDir + '/' + command
options.args.splice(mainIndex, 0, replace)
}
// If the file is just something like 'node' then that'll
// resolve to our shim, and so to prevent double-shimming, we need
// to resolve that here first.
// This also handles the case where there's not a main file, like
// `node -e 'program'`, where we want to avoid the shim entirely.
if (options.file === options.basename) {
var realNode = whichOrUndefined(options.file) || process.execPath
options.file = options.args[0] = realNode
}
debug('mungeNode after', options.file, options.args)
}
function mungeShebang (workingDir, options) {
try {
var resolved = which.sync(options.file)
} catch (er) {
// nothing to do if we can't resolve
// Most likely: file doesn't exist or is not executable.
// Let exec pass through, probably will fail, oh well.
return
}
var shebang = fs.readFileSync(resolved, 'utf8')
var match = shebang.match(/^#!([^\r\n]+)/)
if (!match)
return // not a shebang script, probably a binary
var shebangbin = match[1].split(' ')[0]
var maybeNode = path.basename(shebangbin)
if (!isNode(maybeNode))
return // not a node shebang, leave untouched
options.originalNode = shebangbin
options.basename = maybeNode
options.file = shebangbin
options.args = [shebangbin, workingDir + '/' + maybeNode]
.concat(resolved)
.concat(match[1].split(' ').slice(1))
.concat(options.args.slice(1))
}
function mungeEnv (workingDir, options) {
var pathEnv
for (var i = 0; i < options.envPairs.length; i++) {
var ep = options.envPairs[i]
if (ep.match(pathRe)) {
pathEnv = ep.substr(5)
var k = ep.substr(0, 5)
options.envPairs[i] = k + workingDir + colon + pathEnv
}
}
if (!pathEnv) {
options.envPairs.push((isWindows ? 'Path=' : 'PATH=') + workingDir)
}
if (options.originalNode) {
var key = path.basename(workingDir).substr('.node-spawn-wrap-'.length)
options.envPairs.push('SW_ORIG_' + key + '=' + options.originalNode)
}
if (process.env.SPAWN_WRAP_DEBUG === '1')
options.envPairs.push('SPAWN_WRAP_DEBUG=1')
}
function isnpm (file) {
// XXX is this even possible/necessary?
// wouldn't npm just be detected as a node shebang?
return file === 'npm' && !isWindows
}
function mungenpm (workingDir, options) {
debug('munge npm')
// XXX weird effects of replacing a specific npm with a global one
var npmPath = whichOrUndefined('npm')
if (npmPath) {
options.args[0] = npmPath
options.file = workingDir + '/node'
options.args.unshift(workingDir + '/node')
}
}
function munge (workingDir, options) {
options.basename = path.basename(options.file).replace(/\.exe$/i, '')
// XXX: dry this
if (isSh(options.basename)) {
mungeSh(workingDir, options)
} else if (isCmd(options.basename)) {
mungeCmd(workingDir, options)
} else if (isNode(options.basename)) {
mungeNode(workingDir, options)
} else if (isnpm(options.basename)) {
// XXX unnecessary? on non-windows, npm is just another shebang
mungenpm(workingDir, options)
} else {
mungeShebang(workingDir, options)
}
// now the options are munged into shape.
// whether we changed something or not, we still update the PATH
// so that if a script somewhere calls `node foo`, it gets our
// wrapper instead.
mungeEnv(workingDir, options)
}
function whichOrUndefined (executable) {
var path
try {
path = which.sync(executable)
} catch (er) {}
return path
}
function setup (argv, env) {
if (argv && typeof argv === 'object' && !env && !Array.isArray(argv)) {
env = argv
argv = []
}
if (!argv && !env) {
throw new Error('at least one of "argv" and "env" required')
}
if (argv) {
assert(Array.isArray(argv), 'argv must be array')
} else {
argv = []
}
if (env) {
assert(typeof env === 'object', 'env must be an object')
} else {
env = {}
}
debug('setup argv=%j env=%j', argv, env)
// For stuff like --use_strict or --harmony, we need to inject
// the argument *before* the wrap-main.
var execArgv = []
for (var i = 0; i < argv.length; i++) {
if (argv[i].match(/^-/)) {
execArgv.push(argv[i])
if (argv[i] === '-r' || argv[i] === '--require') {
execArgv.push(argv[++i])
}
} else {
break
}
}
if (execArgv.length) {
if (execArgv.length === argv.length) {
argv.length = 0
} else {
argv = argv.slice(execArgv.length)
}
}
var key = process.pid + '-' + crypto.randomBytes(6).toString('hex')
var workingDir = homedir + key
var settings = JSON.stringify({
module: __filename,
deps: {
foregroundChild: require.resolve('foreground-child'),
signalExit: require.resolve('signal-exit'),
},
key: key,
workingDir: workingDir,
argv: argv,
execArgv: execArgv,
env: env,
root: process.pid
}, null, 2) + '\n'
signalExit(function () {
if (!doDebug)
rimraf.sync(workingDir)
})
mkdirp.sync(workingDir)
workingDir = fs.realpathSync(workingDir)
if (isWindows) {
var cmdShim =
'@echo off\r\n' +
'SETLOCAL\r\n' +
'SET PATHEXT=%PATHEXT:;.JS;=;%\r\n' +
'"' + process.execPath + '"' + ' "%~dp0\\.\\node" %*\r\n'
fs.writeFileSync(workingDir + '/node.cmd', cmdShim)
fs.chmodSync(workingDir + '/node.cmd', '0755')
fs.writeFileSync(workingDir + '/iojs.cmd', cmdShim)
fs.chmodSync(workingDir + '/iojs.cmd', '0755')
}
fs.writeFileSync(workingDir + '/node', shim)
fs.chmodSync(workingDir + '/node', '0755')
fs.writeFileSync(workingDir + '/iojs', shim)
fs.chmodSync(workingDir + '/iojs', '0755')
var cmdname = path.basename(process.execPath).replace(/\.exe$/i, '')
if (cmdname !== 'iojs' && cmdname !== 'node') {
fs.writeFileSync(workingDir + '/' + cmdname, shim)
fs.chmodSync(workingDir + '/' + cmdname, '0755')
}
fs.writeFileSync(workingDir + '/settings.json', settings)
return workingDir
}
function runMain () {
process.argv.splice(1, 1)
process.argv[1] = path.resolve(process.argv[1])
delete require.cache[process.argv[1]]
Module.runMain()
}

View File

@ -0,0 +1,5 @@
module.exports = function () {
return process.platform === 'win32' ||
process.env.OSTYPE === 'cygwin' ||
process.env.OSTYPE === 'msys'
}

View File

@ -0,0 +1,104 @@
{
"_args": [
[
{
"raw": "spawn-wrap@^1.3.8",
"scope": null,
"escapedName": "spawn-wrap",
"name": "spawn-wrap",
"rawSpec": "^1.3.8",
"spec": ">=1.3.8 <2.0.0",
"type": "range"
},
"/Users/benjamincoe/bcoe/nyc"
]
],
"_from": "spawn-wrap@>=1.3.8 <2.0.0",
"_id": "spawn-wrap@1.3.8",
"_inBundle": true,
"_inCache": true,
"_location": "/nyc/spawn-wrap",
"_nodeVersion": "8.0.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/spawn-wrap-1.3.8.tgz_1499381746040_0.7410448391456157"
},
"_npmUser": {
"name": "isaacs",
"email": "i@izs.me"
},
"_npmVersion": "5.1.0",
"_phantomChildren": {},
"_requested": {
"raw": "spawn-wrap@^1.3.8",
"scope": null,
"escapedName": "spawn-wrap",
"name": "spawn-wrap",
"rawSpec": "^1.3.8",
"spec": ">=1.3.8 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/nyc"
],
"_resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-1.3.8.tgz",
"_shasum": "fa2a79b990cbb0bb0018dca6748d88367b19ec31",
"_shrinkwrap": null,
"_spec": "spawn-wrap@^1.3.8",
"_where": "/Users/benjamincoe/bcoe/nyc",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"bugs": {
"url": "https://github.com/isaacs/spawn-wrap/issues"
},
"dependencies": {
"foreground-child": "^1.5.6",
"mkdirp": "^0.5.0",
"os-homedir": "^1.0.1",
"rimraf": "^2.3.3",
"signal-exit": "^3.0.2",
"which": "^1.2.4"
},
"description": "Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.",
"devDependencies": {
"tap": "^10.1.0"
},
"directories": {},
"dist": {
"integrity": "sha512-Yfkd7Yiwz4RcBPrDWzvhnTzQINBHNqOEhUzOdWZ67Y9b4wzs3Gz6ymuptQmRBpzlpOzroM7jwzmBdRec7JJ0UA==",
"shasum": "fa2a79b990cbb0bb0018dca6748d88367b19ec31",
"tarball": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-1.3.8.tgz"
},
"files": [
"index.js",
"shim.js",
"lib/is-windows.js"
],
"gitHead": "4b269f316e8da220fab8449f0fe60d34813db027",
"homepage": "https://github.com/isaacs/spawn-wrap#readme",
"license": "ISC",
"main": "index.js",
"maintainers": [
{
"name": "isaacs",
"email": "i@izs.me"
}
],
"name": "spawn-wrap",
"optionalDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/isaacs/spawn-wrap.git"
},
"scripts": {
"clean": "rm -rf ~/.node-spawn-wrap-*",
"postpublish": "git push origin --all; git push origin --tags",
"postversion": "npm publish",
"preversion": "npm test",
"test": "tap test/*.js"
},
"version": "1.3.8"
}

View File

@ -0,0 +1,180 @@
'use strict'
// This module should *only* be loaded as a main script
// by child processes wrapped by spawn-wrap. It sets up
// argv to include the injected argv (including the user's
// wrapper script) and any environment variables specified.
//
// If any argv were passed in (ie, if it's used to force
// a wrapper script, and not just ensure that an env is kept
// around through all the child procs), then we also set up
// a require('spawn-wrap').runMain() function that will strip
// off the injected arguments and run the main file.
// wrap in iife for babylon to handle module-level return
;(function () {
if (module !== require.main) {
throw new Error('spawn-wrap: cli wrapper invoked as non-main script')
}
var util
var doDebug = process.env.SPAWN_WRAP_DEBUG === '1'
var fs
function debug () {
if (!doDebug)
return
if (!fs) {
fs = require('fs')
util = require('util')
}
var message = util.format.apply(util, arguments).trim()
var pref = 'SW ' + process.pid + ': '
message = pref + message.split('\n').join('\n' + pref)
fs.writeSync(2, message + '\n')
}
debug('shim', [process.argv[0]].concat(process.execArgv, process.argv.slice(1)))
var Module = require('module')
var assert = require('assert')
var path = require('path')
var settings = require('./settings.json')
var foregroundChild = require(settings.deps.foregroundChild)
var argv = settings.argv
var nargs = argv.length
var env = settings.env
var key = settings.key
var node = process.env['SW_ORIG_' + key] || process.execPath
for (var k in env) {
process.env[k] = env[k]
}
var needExecArgv = settings.execArgv || []
// If the user added their OWN wrapper pre-load script, then
// this will pop that off of the argv, and load the "real" main
function runMain () {
debug('runMain pre', process.argv)
process.argv.splice(1, nargs)
process.argv[1] = path.resolve(process.argv[1])
delete require.cache[process.argv[1]]
debug('runMain post', process.argv)
Module.runMain()
debug('runMain after')
}
// Argv coming in looks like:
// bin shim execArgv main argv
//
// Turn it into:
// bin settings.execArgv execArgv settings.argv main argv
//
// If we don't have a main script, then just run with the necessary
// execArgv
var hasMain = false
for (var a = 2; !hasMain && a < process.argv.length; a++) {
switch (process.argv[a]) {
case '-i':
case '--interactive':
case '--eval':
case '-e':
case '-p':
case '-pe':
hasMain = false
a = process.argv.length
continue
case '-r':
case '--require':
a += 1
continue
default:
if (process.argv[a].match(/^-/)) {
continue
} else {
hasMain = a
a = process.argv.length
break
}
}
}
debug('after argv parse hasMain=%j', hasMain)
if (hasMain > 2) {
// if the main file is above #2, then it means that there
// was a --exec_arg *before* it. This means that we need
// to slice everything from 2 to hasMain, and pass that
// directly to node. This also splices out the user-supplied
// execArgv from the argv.
var addExecArgv = process.argv.splice(2, hasMain - 2)
needExecArgv.push.apply(needExecArgv, addExecArgv)
}
if (!hasMain) {
// we got loaded by mistake for a `node -pe script` or something.
var args = process.execArgv.concat(needExecArgv, process.argv.slice(2))
debug('no main file!', args)
foregroundChild(node, args)
return
}
// If there are execArgv, and they're not the same as how this module
// was executed, then we need to inject those. This is for stuff like
// --harmony or --use_strict that needs to be *before* the main
// module.
if (needExecArgv.length) {
var pexec = process.execArgv
if (JSON.stringify(pexec) !== JSON.stringify(needExecArgv)) {
debug('need execArgv for this', pexec, '=>', needExecArgv)
var spawn = require('child_process').spawn
var sargs = pexec.concat(needExecArgv).concat(process.argv.slice(1))
foregroundChild(node, sargs)
return
}
}
// At this point, we've verified that we got the correct execArgv,
// and that we have a main file, and that the main file is sitting at
// argv[2]. Splice this shim off the list so it looks like the main.
var spliceArgs = [1, 1].concat(argv)
process.argv.splice.apply(process.argv, spliceArgs)
// Unwrap the PATH environment var so that we're not mucking
// with the environment. It'll get re-added if they spawn anything
var isWindows = (
process.platform === 'win32' ||
process.env.OSTYPE === 'cygwin' ||
process.env.OSTYPE === 'msys'
)
if (isWindows) {
for (var i in process.env) {
if (i.match(/^path$/i)) {
process.env[i] = process.env[i].replace(__dirname + ';', '')
}
}
} else {
process.env.PATH = process.env.PATH.replace(__dirname + ':', '')
}
var spawnWrap = require(settings.module)
if (nargs) {
spawnWrap.runMain = function (original) { return function () {
spawnWrap.runMain = original
runMain()
}}(spawnWrap.runMain)
}
spawnWrap(argv, env, __dirname)
debug('shim runMain', process.argv)
delete require.cache[process.argv[1]]
Module.runMain()
// end iife wrapper for babylon
})()