{"_id":"pandora-spawn-wrap","_rev":"371710","name":"pandora-spawn-wrap","description":"Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.","dist-tags":{"latest":"1.0.3"},"maintainers":[{"name":"guangwong","email":"guangwong@gmail.com"}],"time":{"modified":"2021-07-27T02:39:04.000Z","created":"2017-12-06T10:02:22.555Z","1.0.3":"2018-03-16T06:16:14.271Z","1.0.2":"2018-03-16T04:18:39.668Z","1.0.1":"2017-12-06T10:05:38.055Z","1.0.0":"2017-12-06T10:02:22.555Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/midwayjs/spawn-wrap.git"},"versions":{"1.0.3":{"name":"pandora-spawn-wrap","version":"1.0.3","description":"Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.","main":"index.js","dependencies":{"foreground-child":"^1.5.6","mkdirp":"^0.5.0","os-homedir":"^1.0.1","rimraf":"^2.6.2","which":"^1.3.0"},"scripts":{"test":"tap --timeout=240 test/*.js","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags","clean":"rm -rf ~/.node-spawn-wrap-*"},"repository":{"type":"git","url":"git+https://github.com/midwayjs/spawn-wrap.git"},"license":"ISC","bugs":{"url":"https://github.com/midwayjs/spawn-wrap/issues"},"homepage":"https://github.com/midwayjs/spawn-wrap","devDependencies":{"signal-exit":"^3.0.2","tap":"^10.7.3"},"files":["index.js","shim.js","lib/is-windows.js"],"gitHead":"483d9ee1edf5018f05d9d53bbc3432dc182af43c","_id":"pandora-spawn-wrap@1.0.3","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"guangwong","email":"guangwong@gmail.com"},"dist":{"shasum":"24ba857ed57f005e2622c3ee051303acf45dbf8a","size":8664,"noattachment":false,"key":"/pandora-spawn-wrap/-/pandora-spawn-wrap-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandora-spawn-wrap/download/pandora-spawn-wrap-1.0.3.tgz"},"maintainers":[{"name":"guangwong","email":"guangwong@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandora-spawn-wrap_1.0.3_1521180974223_0.6950767686505104"},"_hasShrinkwrap":false,"publish_time":1521180974271,"_cnpm_publish_time":1521180974271},"1.0.2":{"name":"pandora-spawn-wrap","version":"1.0.2","description":"Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.","main":"index.js","dependencies":{"foreground-child":"^1.5.6","mkdirp":"^0.5.0","os-homedir":"^1.0.1","rimraf":"^2.6.2","which":"^1.3.0"},"scripts":{"test":"tap --timeout=240 test/*.js","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags","clean":"rm -rf ~/.node-spawn-wrap-*"},"repository":{"type":"git","url":"git+https://github.com/midwayjs/spawn-wrap.git"},"license":"ISC","bugs":{"url":"https://github.com/midwayjs/spawn-wrap/issues"},"homepage":"https://github.com/midwayjs/spawn-wrap","devDependencies":{"signal-exit":"^3.0.2","tap":"^10.7.3"},"files":["index.js","shim.js","lib/is-windows.js"],"gitHead":"4176000523ac0cc8e9d9569c75dac16b1bfabe8a","_id":"pandora-spawn-wrap@1.0.2","_npmVersion":"5.6.0","_nodeVersion":"8.10.0","_npmUser":{"name":"guangwong","email":"guangwong@gmail.com"},"dist":{"shasum":"525d48bb3ada757e6f53024f56986e8e0cede30f","size":8646,"noattachment":false,"key":"/pandora-spawn-wrap/-/pandora-spawn-wrap-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandora-spawn-wrap/download/pandora-spawn-wrap-1.0.2.tgz"},"maintainers":[{"name":"guangwong","email":"guangwong@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandora-spawn-wrap_1.0.2_1521173919603_0.050686047373897036"},"_hasShrinkwrap":false,"publish_time":1521173919668,"_cnpm_publish_time":1521173919668},"1.0.1":{"name":"pandora-spawn-wrap","version":"1.0.1","description":"Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.","main":"index.js","dependencies":{"foreground-child":"^1.5.6","mkdirp":"^0.5.0","os-homedir":"^1.0.1","rimraf":"^2.6.2","which":"^1.3.0"},"scripts":{"test":"tap --timeout=240 test/*.js","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags","clean":"rm -rf ~/.node-spawn-wrap-*"},"repository":{"type":"git","url":"git+https://github.com/midwayjs/spawn-wrap.git"},"license":"ISC","bugs":{"url":"https://github.com/midwayjs/spawn-wrap/issues"},"homepage":"https://github.com/midwayjs/spawn-wrap","devDependencies":{"signal-exit":"^3.0.2","tap":"^10.7.3"},"files":["index.js","shim.js","lib/is-windows.js"],"gitHead":"bc518f131d7c60020966443c7858c5d3adffa7c5","_id":"pandora-spawn-wrap@1.0.1","_shasum":"bf5e579ba63ce8a71e5833a87aa26c93499c3893","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.9.1","_npmUser":{"name":"guangwong","email":"guangwong@gmail.com"},"dist":{"shasum":"bf5e579ba63ce8a71e5833a87aa26c93499c3893","size":8546,"noattachment":false,"key":"/pandora-spawn-wrap/-/pandora-spawn-wrap-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandora-spawn-wrap/download/pandora-spawn-wrap-1.0.1.tgz"},"maintainers":[{"name":"guangwong","email":"guangwong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandora-spawn-wrap-1.0.1.tgz_1512554737975_0.7918464795220643"},"directories":{},"publish_time":1512554738055,"_hasShrinkwrap":false,"_cnpm_publish_time":1512554738055},"1.0.0":{"name":"pandora-spawn-wrap","version":"1.0.0","description":"Wrap all spawned Node.js child processes by adding environs and arguments ahead of the main JavaScript file argument.","main":"index.js","dependencies":{"foreground-child":"^1.5.6","mkdirp":"^0.5.0","os-homedir":"^1.0.1","rimraf":"^2.6.2","which":"^1.3.0"},"scripts":{"test":"tap --timeout=240 test/*.js","preversion":"npm test","postversion":"npm publish","postpublish":"git push origin --all; git push origin --tags","clean":"rm -rf ~/.node-spawn-wrap-*"},"repository":{"type":"git","url":"git+https://github.com/isaacs/spawn-wrap.git"},"author":{"name":"Isaac Z. Schlueter","email":"i@izs.me","url":"http://blog.izs.me/"},"license":"ISC","bugs":{"url":"https://github.com/isaacs/spawn-wrap/issues"},"homepage":"https://github.com/isaacs/spawn-wrap#readme","devDependencies":{"signal-exit":"^3.0.2","tap":"^10.7.3"},"files":["index.js","shim.js","lib/is-windows.js"],"gitHead":"14e45ef8a9c0824a3398a724256881826c708452","_id":"pandora-spawn-wrap@1.0.0","_shasum":"c8eee6ad6da513e701fe7a4781696a147b451274","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.9.1","_npmUser":{"name":"guangwong","email":"guangwong@gmail.com"},"dist":{"shasum":"c8eee6ad6da513e701fe7a4781696a147b451274","size":8578,"noattachment":false,"key":"/pandora-spawn-wrap/-/pandora-spawn-wrap-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pandora-spawn-wrap/download/pandora-spawn-wrap-1.0.0.tgz"},"maintainers":[{"name":"guangwong","email":"guangwong@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pandora-spawn-wrap-1.0.0.tgz_1512554542453_0.8274718038737774"},"directories":{},"publish_time":1512554542555,"_hasShrinkwrap":false,"_cnpm_publish_time":1512554542555}},"readme":"# spawn-wrap\n\nWrap all spawned Node.js child processes by adding environs and\narguments ahead of the main JavaScript file argument.\n\nAny child processes launched by that child process will also be\nwrapped in a similar fashion.\n\nThis is a bit of a brutal hack, designed primarily to support code\ncoverage reporting in cases where tests or the system under test are\nloaded via child processes rather than via `require()`.\n\nIt can also be handy if you want to run your own mock executable\ninstead of some other thing when child procs call into it.\n\n[![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)\n\n## USAGE\n\n```javascript\nvar wrap = require('spawn-wrap')\n\n// wrap(wrapperArgs, environs)\nvar unwrap = wrap(['/path/to/my/main.js', 'foo=bar'], { FOO: 1 })\n\n// later to undo the wrapping, you can call the returned function\nunwrap()\n```\n\nIn this example, the `/path/to/my/main.js` file will be used as the\n\"main\" module, whenever any Node or io.js child process is started,\nwhether via a call to `spawn` or `exec`, whether node is invoked\ndirectly as the command or as the result of a shebang `#!` lookup.\n\nIn `/path/to/my/main.js`, you can do whatever instrumentation or\nenvironment manipulation you like.  When you're done, and ready to run\nthe \"real\" main.js file (ie, the one that was spawned in the first\nplace), you can do this:\n\n```javascript\n// /path/to/my/main.js\n// process.argv[1] === 'foo=bar'\n// and process.env.FOO === '1'\n\n// my wrapping manipulations\nsetupInstrumentationOrCoverageOrWhatever()\nprocess.on('exit', function (code) {\n  storeCoverageInfoSynchronously()\n})\n\n// now run the instrumented and covered or whatever codes\nrequire('spawn-wrap').runMain()\n```\n\n## ENVIRONMENT VARIABLES\n\nSpawn-wrap responds to two environment variables, both of which are\npreserved through child processes.\n\n`SPAWN_WRAP_DEBUG=1` in the environment will make this module dump a\nlot of information to stderr.\n\n`SPAWN_WRAP_SHIM_ROOT` can be set to a path on the filesystem where\nthe shim files are written in a `.node-spawn-wrap-<id>` folder.  By\ndefault this is done in `$HOME`, but in some environments you may wish\nto point it at some other root.  (For example, if `$HOME` is mounted\nas read-only in a virtual machine or container.)\n\n## CONTRACTS and CAVEATS\n\nThe initial wrap call uses synchronous I/O.  Probably you should not\nbe using this script in any production environments anyway.\n\nAlso, this will slow down child process execution by a lot, since\nwe're adding a few layers of indirection.\n\nThe contract which this library aims to uphold is:\n\n* Wrapped processes behave identical to their unwrapped counterparts\n  for all intents and purposes.  That means that the wrapper script\n  propagates all signals and exit codes.\n* If you send a signal to the wrapper, the child gets the signal.\n* If the child exits with a numeric status code, then the wrapper\n  exits with that code.\n* If the child dies with a signal, then the wrapper dies with the\n  same signal.\n* If you execute any Node child process, in any of the various ways\n  that such a thing can be done, it will be wrapped.\n* Children of wrapped processes are also wrapped.\n\n(Much of this made possible by\n[foreground-child](http://npm.im/foreground-child).)\n\nThere are a few ways situations in which this contract cannot be\nadhered to, despite best efforts:\n\n1. In order to handle cases where `node` is invoked in a shell script,\n   the `PATH` environment variable is modified such that the the shim\n   will be run before the \"real\" node.  However, since Windows does\n   not allow executing shebang scripts like regular programs, a\n   `node.cmd` file is required.\n2. Signal propagation through `dash` doesn't always work.  So, if you\n   use `child_process.exec()` on systems where `/bin/sh` is actually\n   `dash`, then the process may exit with a status code > 128 rather\n   than indicating that it received a signal.\n3. `cmd.exe` is even stranger with how it propagates and interprets\n   unix signals.  If you want your programs to be portable, then\n   probably you wanna not rely on signals too much.\n4. It *is* possible to escape the wrapping, if you spawn a bash\n   script, and that script modifies the `PATH`, and then calls a\n   specific `node` binary explicitly.\n","_attachments":{},"homepage":"https://github.com/midwayjs/spawn-wrap","bugs":{"url":"https://github.com/midwayjs/spawn-wrap/issues"},"license":"ISC"}