UNPKG

motion

Version:

motion - moving development forward

72 lines (71 loc) 4.56 kB
{ "_args": [ [ "flagged-respawn@https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.1.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "flagged-respawn@>=0.3.1 <0.4.0", "_id": "flagged-respawn@0.3.1", "_inCache": true, "_location": "/flagged-respawn", "_phantomChildren": {}, "_requested": { "name": "flagged-respawn", "raw": "flagged-respawn@https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.1.tgz", "rawSpec": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.1.tgz", "scope": null, "spec": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.1.tgz", "type": "remote" }, "_requiredBy": [ "/liftoff" ], "_resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.1.tgz", "_shasum": "397700925df6e12452202a71e89d89545fbbbe9d", "_shrinkwrap": null, "_spec": "flagged-respawn@https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-0.3.1.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "name": "Tyler Kellen", "url": "http://goingslowly.com/" }, "bugs": { "url": "https://github.com/tkellen/node-flagged-respawn/issues" }, "dependencies": {}, "description": "A tool for respawning node binaries when special flags are present.", "devDependencies": { "chai": "~1.9.1", "mocha": "~1.21.4", "v8flags": "~1.0.1" }, "engines": { "node": ">= 0.8.0" }, "homepage": "https://github.com/tkellen/node-flagged-respawn", "keywords": [ "respawn flags" ], "licenses": [ { "type": "MIT", "url": "https://github.com/tkellen/node-flagged-respawn/blob/master/LICENSE" } ], "main": "index.js", "name": "flagged-respawn", "optionalDependencies": {}, "readme": "# flagged-respawn [![Build Status](https://secure.travis-ci.org/tkellen/node-flagged-respawn.png)](http://travis-ci.org/tkellen/node-flagged-respawn)\n> A tool for respawning node binaries when special flags are present.\n\n[![NPM](https://nodei.co/npm/flagged-respawn.png)](https://nodei.co/npm/flagged-respawn/)\n\n## What is it?\n\nSay you wrote a command line tool that runs arbitrary javascript (e.g. task runner, test framework, etc). For the sake of discussion, let's pretend it's a testing harness you've named `testify`.\n\nEverything is going splendidly until one day you decide to test some code that relies on a feature behind a v8 flag in node (`--harmony`, for example). Without much thought, you run `testify --harmony spec tests.js`.\n\nIt doesn't work. After digging around for a bit, you realize this produces a [`process.argv`](http://nodejs.org/docs/latest/api/process.html#process_process_argv) of:\n\n`['node', '/usr/local/bin/test', '--harmony', 'spec', 'tests.js']`\n\nCrap. The `--harmony` flag is in the wrong place! It should be applied to the **node** command, not our binary. What we actually wanted was this:\n\n`['node', '--harmony', '/usr/local/bin/test', 'spec', 'tests.js']`\n\nFlagged-respawn fixes this problem and handles all the edge cases respawning creates, such as:\n- Providing a method to determine if a respawn is needed.\n- Piping stderr/stdout from the child into the parent.\n- Making the parent process exit with the same code as the child.\n- If the child is killed, making the parent exit with the same signal.\n\nTo see it in action, clone this repository and run `npm install` / `npm run respawn` / `npm run nospawn`.\n\n## Sample Usage\n\n```js\n#!/usr/bin/env node\n\nconst flaggedRespawn = require('flagged-respawn');\n\n// get a list of all possible v8 flags for the running version of node\nconst v8flags = require('v8flags').fetch();\n\nflaggedRespawn(v8flags, process.argv, function (ready, child) {\n if (ready) {\n console.log('Running!');\n // your cli code here\n } else {\n console.log('Special flags found, respawning.');\n }\n if (process.pid !== child.pid) {\n console.log('Respawned to PID:', child.pid);\n }\n});\n\n```\n\n## Release History\n\n* 2014-09-12 - v0.3.1 - use `{ stdio: 'inherit' }` for spawn to maintain colors\n* 2014-09-11 - v0.3.0 - for real this time\n* 2014-09-11 - v0.2.0 - cleanup\n* 2014-09-04 - v0.1.1 - initial release\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/tkellen/node-flagged-respawn.git" }, "scripts": { "nospawn": "node test/bin/respawner test", "respawn": "node test/bin/respawner --harmony test", "test": "mocha -R spec test" }, "version": "0.3.1" }