Fix actions/tour
This commit is contained in:
		
							
								
								
									
										21
									
								
								node_modules/flagged-respawn/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								node_modules/flagged-respawn/LICENSE
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| The MIT License (MIT) | ||||
|  | ||||
| Copyright (c) 2014-2018, 2021 Tyler Kellen <tyler@sleekcode.net>, Blaine Bublitz <blaine.bublitz@gmail.com>, and Eric Schoffstall <yo@contra.io> | ||||
|  | ||||
| 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. | ||||
							
								
								
									
										106
									
								
								node_modules/flagged-respawn/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								node_modules/flagged-respawn/README.md
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,106 @@ | ||||
| <p align="center"> | ||||
|   <a href="http://gulpjs.com"> | ||||
|     <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png"> | ||||
|   </a> | ||||
| </p> | ||||
|  | ||||
| # flagged-respawn | ||||
|  | ||||
| [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] | ||||
|  | ||||
| A tool for respawning node binaries when special flags are present. | ||||
|  | ||||
| ## What is it? | ||||
|  | ||||
| Say 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`. | ||||
|  | ||||
| Everything 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`. | ||||
|  | ||||
| It 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: | ||||
|  | ||||
| `['node', '/usr/local/bin/test', '--harmony', 'spec', 'tests.js']` | ||||
|  | ||||
| Crap. 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: | ||||
|  | ||||
| `['node', '--harmony', '/usr/local/bin/test', 'spec', 'tests.js']` | ||||
|  | ||||
| Flagged-respawn fixes this problem and handles all the edge cases respawning creates, such as: | ||||
|  | ||||
| - Providing a method to determine if a respawn is needed. | ||||
| - Piping stderr/stdout from the child into the parent. | ||||
| - Making the parent process exit with the same code as the child. | ||||
| - If the child is killed, making the parent exit with the same signal. | ||||
|  | ||||
| To see it in action, clone this repository and run `npm install` / `npm run respawn` / `npm run nospawn`. | ||||
|  | ||||
| ## Sample Usage | ||||
|  | ||||
| ```js | ||||
| #!/usr/bin/env node | ||||
|  | ||||
| const flaggedRespawn = require('flagged-respawn'); | ||||
|  | ||||
| // get a list of all possible v8 flags for the running version of node | ||||
| const v8flags = require('v8flags').fetch(); | ||||
|  | ||||
| flaggedRespawn(v8flags, process.argv, function (ready, child) { | ||||
|   if (ready) { | ||||
|     console.log('Running!'); | ||||
|     // your cli code here | ||||
|   } else { | ||||
|     console.log('Special flags found, respawning.'); | ||||
|   } | ||||
|   if (process.pid !== child.pid) { | ||||
|     console.log('Respawned to PID:', child.pid); | ||||
|   } | ||||
| }); | ||||
| ``` | ||||
|  | ||||
| ## API | ||||
|  | ||||
| ### <u>flaggedRespawn(flags, argv, [ forcedFlags, ] callback) : Void</u> | ||||
|  | ||||
| Respawns the script itself when _argv_ has special flag contained in _flags_ and/or _forcedFlags_ is not empty. Because members of _flags_ and _forcedFlags_ are passed to `node` command, each of them needs to be a node flag or a V8 flag. | ||||
|  | ||||
| #### Forbid respawning | ||||
|  | ||||
| If `--no-respawning` flag is given in _argv_, this function does not respawned even if _argv_ contains members of flags or _forcedFlags_ is not empty. (This flag is also used internally to prevent from respawning more than once). | ||||
|  | ||||
| #### Parameter: | ||||
|  | ||||
| | Parameter     |      Type       | Description                                                                              | | ||||
| | :------------ | :-------------: | :--------------------------------------------------------------------------------------- | | ||||
| | _flags_       |      Array      | An array of node flags and V8 flags which are available when present in _argv_.          | | ||||
| | _argv_        |      Array      | Command line arguments to respawn.                                                       | | ||||
| | _forcedFlags_ | Array or String | An array of node flags or a string of a single flag and V8 flags for respawning forcely. | | ||||
| | _callback_    |    function     | A called function when not respawning or after respawned.                                | | ||||
|  | ||||
| - **<u><i>callback</i>(ready, proc, argv) : Void</u>** | ||||
|  | ||||
|   _callback_ function is called both when respawned or not, and it can be distinguished by callback's argument: _ready_. (_ready_ indicates whether a process spawned its child process (false) or not (true), but it does not indicate whether a process is a spawned child process or not. _ready_ for a spawned child process is true.) | ||||
|  | ||||
|   _argv_ is an array of command line arguments which is respawned (when _ready_ is false) or is passed current process except flags within _flags_ and `--no-respawning` (when _ready_ is true). | ||||
|  | ||||
|   **Parameter:** | ||||
|  | ||||
|   | Parameter |  Type   | Description                                                          | | ||||
|   | :-------- | :-----: | :------------------------------------------------------------------- | | ||||
|   | _ready_   | boolean | True, if not respawning and is ready to execute main function.       | | ||||
|   | _proc_    | object  | Child process object if respawned, otherwise current process object. | | ||||
|   | _argv_    |  Array  | An array of command line arguments.                                  | | ||||
|  | ||||
| ## License | ||||
|  | ||||
| MIT | ||||
|  | ||||
| <!-- prettier-ignore-start --> | ||||
| [downloads-image]: https://img.shields.io/npm/dm/flagged-respawn.svg?style=flat-square | ||||
| [npm-url]: https://www.npmjs.com/package/flagged-respawn | ||||
| [npm-image]: https://img.shields.io/npm/v/flagged-respawn.svg?style=flat-square | ||||
|  | ||||
| [ci-url]: https://github.com/gulpjs/flagged-respawn/actions?query=workflow:dev | ||||
| [ci-image]: https://img.shields.io/github/workflow/status/gulpjs/flagged-respawn/dev?style=flat-square | ||||
|  | ||||
| [coveralls-url]: https://coveralls.io/r/gulpjs/flagged-respawn | ||||
| [coveralls-image]: https://img.shields.io/coveralls/gulpjs/flagged-respawn/master.svg?style=flat-square | ||||
| <!-- prettier-ignore-end --> | ||||
							
								
								
									
										53
									
								
								node_modules/flagged-respawn/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								node_modules/flagged-respawn/index.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,53 @@ | ||||
| var reorder = require('./lib/reorder'); | ||||
| var respawn = require('./lib/respawn'); | ||||
| var remover = require('./lib/remover'); | ||||
|  | ||||
| var FORBID_RESPAWNING_FLAG = '--no-respawning'; | ||||
|  | ||||
| module.exports = function (flags, argv, forcedFlags, execute) { | ||||
|   if (!flags) { | ||||
|     throw new Error('You must specify flags to respawn with.'); | ||||
|   } | ||||
|   if (!argv) { | ||||
|     throw new Error('You must specify an argv array.'); | ||||
|   } | ||||
|  | ||||
|   if (typeof forcedFlags === 'function') { | ||||
|     execute = forcedFlags; | ||||
|     forcedFlags = []; | ||||
|   } | ||||
|  | ||||
|   if (typeof forcedFlags === 'string') { | ||||
|     forcedFlags = [forcedFlags]; | ||||
|   } | ||||
|  | ||||
|   if (!Array.isArray(forcedFlags)) { | ||||
|     forcedFlags = []; | ||||
|   } | ||||
|  | ||||
|   var index = argv.indexOf(FORBID_RESPAWNING_FLAG); | ||||
|   if (index >= 0) { | ||||
|     argv = argv.slice(0, index).concat(argv.slice(index + 1)); | ||||
|     argv = remover(flags, argv); | ||||
|     execute(true, process, argv); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   var proc = process; | ||||
|   var reordered = reorder(flags, argv); | ||||
|   var ready = JSON.stringify(argv) === JSON.stringify(reordered); | ||||
|  | ||||
|   if (forcedFlags.length) { | ||||
|     reordered = reordered | ||||
|       .slice(0, 1) | ||||
|       .concat(forcedFlags) | ||||
|       .concat(reordered.slice(1)); | ||||
|     ready = false; | ||||
|   } | ||||
|  | ||||
|   if (!ready) { | ||||
|     reordered.push(FORBID_RESPAWNING_FLAG); | ||||
|     proc = respawn(reordered); | ||||
|   } | ||||
|   execute(ready, proc, reordered); | ||||
| }; | ||||
							
								
								
									
										5
									
								
								node_modules/flagged-respawn/lib/is-v8flags.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								node_modules/flagged-respawn/lib/is-v8flags.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| function isV8flags(flag, v8flags) { | ||||
|   return v8flags.indexOf(flag) >= 0; | ||||
| } | ||||
|  | ||||
| module.exports = isV8flags; | ||||
							
								
								
									
										13
									
								
								node_modules/flagged-respawn/lib/remover.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								node_modules/flagged-respawn/lib/remover.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| var isV8flags = require('./is-v8flags'); | ||||
|  | ||||
| module.exports = function (flags, argv) { | ||||
|   var args = argv.slice(0, 1); | ||||
|   for (var i = 1, n = argv.length; i < n; i++) { | ||||
|     var arg = argv[i]; | ||||
|     var flag = arg.split('=')[0]; | ||||
|     if (!isV8flags(flag, flags)) { | ||||
|       args.push(arg); | ||||
|     } | ||||
|   } | ||||
|   return args; | ||||
| }; | ||||
							
								
								
									
										18
									
								
								node_modules/flagged-respawn/lib/reorder.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								node_modules/flagged-respawn/lib/reorder.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
| var isV8flags = require('./is-v8flags'); | ||||
|  | ||||
| module.exports = function (flags, argv) { | ||||
|   if (!argv) { | ||||
|     argv = process.argv; | ||||
|   } | ||||
|   var args = [argv[1]]; | ||||
|   argv.slice(2).forEach(function (arg) { | ||||
|     var flag = arg.split('=')[0]; | ||||
|     if (isV8flags(flag, flags)) { | ||||
|       args.unshift(arg); | ||||
|     } else { | ||||
|       args.push(arg); | ||||
|     } | ||||
|   }); | ||||
|   args.unshift(argv[0]); | ||||
|   return args; | ||||
| }; | ||||
							
								
								
									
										16
									
								
								node_modules/flagged-respawn/lib/respawn.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								node_modules/flagged-respawn/lib/respawn.js
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,16 @@ | ||||
| var spawn = require('child_process').spawn; | ||||
|  | ||||
| module.exports = function (argv) { | ||||
|   var child = spawn(argv[0], argv.slice(1), { stdio: 'inherit' }); | ||||
|   child.on('exit', function (code, signal) { | ||||
|     process.on('exit', function () { | ||||
|       /* istanbul ignore if */ | ||||
|       if (signal) { | ||||
|         process.kill(process.pid, signal); | ||||
|       } else { | ||||
|         process.exit(code); | ||||
|       } | ||||
|     }); | ||||
|   }); | ||||
|   return child; | ||||
| }; | ||||
							
								
								
									
										50
									
								
								node_modules/flagged-respawn/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										50
									
								
								node_modules/flagged-respawn/package.json
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,50 @@ | ||||
| { | ||||
|   "name": "flagged-respawn", | ||||
|   "version": "2.0.0", | ||||
|   "description": "A tool for respawning node binaries when special flags are present.", | ||||
|   "author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)", | ||||
|   "contributors": [ | ||||
|     "Takayuki Sato <sttk.xslet@gmail.com>", | ||||
|     "Bertrand Marron <bertrand.marron@ionisx.com>", | ||||
|     "Tyler Kellen <tyler@sleekcode.net>", | ||||
|     "Blaine Bublitz <blaine.bublitz@gmail.com>" | ||||
|   ], | ||||
|   "repository": "gulpjs/flagged-respawn", | ||||
|   "license": "MIT", | ||||
|   "engines": { | ||||
|     "node": ">= 10.13.0" | ||||
|   }, | ||||
|   "main": "index.js", | ||||
|   "files": [ | ||||
|     "index.js", | ||||
|     "lib/", | ||||
|     "LICENSE" | ||||
|   ], | ||||
|   "scripts": { | ||||
|     "lint": "eslint .", | ||||
|     "pretest": "npm run lint", | ||||
|     "test": "nyc mocha --async-only" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "eslint": "^7.32.0", | ||||
|     "eslint-config-gulp": "^5.0.1", | ||||
|     "eslint-plugin-node": "^11.1.0", | ||||
|     "expect": "^27.3.1", | ||||
|     "mocha": "^8.4.0", | ||||
|     "nyc": "^15.1.0", | ||||
|     "v8flags": "^4.0.0" | ||||
|   }, | ||||
|   "nyc": { | ||||
|     "reporter": [ | ||||
|       "lcov", | ||||
|       "text-summary" | ||||
|     ] | ||||
|   }, | ||||
|   "prettier": { | ||||
|     "singleQuote": true | ||||
|   }, | ||||
|   "keywords": [ | ||||
|     "respawn", | ||||
|     "flags" | ||||
|   ] | ||||
| } | ||||
		Reference in New Issue
	
	Block a user