This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

99
node_modules/foreground-child/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,99 @@
# Changes
## v2.0.0
* BREAKING CHANGE: Require Node 8
* Internal: Add lock file
* Support async before exit callback
* Update various dependencies
## v1.5.6
* Fix 'childHangup is undefined'
## v1.5.5
* add files list to package.json
* neveragain.tech pledge request
## v1.5.4
* update tap to v8
* Let the child decide if signals should be fatal
## v1.5.3
* bump deps
## v1.5.2
* add an automatic changelog script
* replace cross-spawn-async with cross-spawn
* test: stay alive long enough to be signaled
## v1.5.1
* avoid race condition in test
* Use fd numbers instead of 'inherit' for Node v0.10 compatibility
## v1.5.0
* add caveats re IPC and arbitrary FDs
* Forward IPC messages to foregrounded child process
## v1.4.0
* Set `process.exitCode` based on the childs exit code
## v1.3.5
* Better testing for when cross-spawn-async needed
* appveyor: node v0.10 on windows is too flaky
## v1.3.4
* Only use cross-spawn-async for shebangs
* update vanity badges and package.json for repo move
* appveyor
## v1.3.3
* Skip signals in tests on Windows
* update to tap@4
* use cross-spawn-async on windows
## v1.3.2
* Revert "switch to win-spawn"
* Revert "Transparently translate high-order exit code to appropriate signal"
* update travis versions
* Transparently translate high-order exit code to appropriate signal
* ignore coverage folder
## v1.3.1
* switch to win-spawn
## v1.3.0
* note skipped test in test output
* left an unused var c in
* slice arguments, added documentation
* added a unit test, because I strive to be a good open-source-citizen
* make travis also work on 0.12 and iojs again
* added badge
* patch for travis exit weirdness
* fix typo in .gitignore
* beforeExit hook
## v1.2.0
* Use signal-exit, fix kill(process.pid) race
## v1.1.0
* Enforce that parent always gets a 'exit' event
## v1.0.0
* first

15
node_modules/foreground-child/LICENSE generated vendored Normal file
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.

62
node_modules/foreground-child/README.md generated vendored Normal file
View File

@@ -0,0 +1,62 @@
# foreground-child
[![Build Status](https://travis-ci.org/tapjs/foreground-child.svg)](https://travis-ci.org/tapjs/foreground-child) [![Build status](https://ci.appveyor.com/api/projects/status/kq9ylvx9fyr9khx0?svg=true)](https://ci.appveyor.com/project/isaacs/foreground-child)
Run a child as if it's the foreground process. Give it stdio. Exit
when it exits.
Mostly this module is here to support some use cases around wrapping
child processes for test coverage and such.
## USAGE
```js
var foreground = require('foreground-child')
// cats out this file
var child = foreground('cat', [__filename])
// At this point, it's best to just do nothing else.
// return or whatever.
// If the child gets a signal, or just exits, then this
// parent process will exit in the same way.
```
A callback can optionally be provided, if you want to perform an action
before your foreground-child exits:
```js
var child = foreground('cat', [__filename], function (done) {
// perform an action.
return done()
})
```
The callback can return a Promise instead of calling `done`:
```js
var child = foreground('cat', [__filename], async function () {
// perform an action.
})
```
The callback must not throw or reject.
## Caveats
The "normal" standard IO file descriptors (0, 1, and 2 for stdin,
stdout, and stderr respectively) are shared with the child process.
Additionally, if there is an IPC channel set up in the parent, then
messages are proxied to the child on file descriptor 3.
However, in Node, it's possible to also map arbitrary file descriptors
into a child process. In these cases, foreground-child will not map
the file descriptors into the child. If file descriptors 0, 1, or 2
are used for the IPC channel, then strange behavior may happen (like
printing IPC messages to stderr, for example).
Note that a SIGKILL will always kill the parent process, _and never
the child process_, because SIGKILL cannot be caught or proxied. The
only way to do this would be if Node provided a way to truly exec a
process as the new foreground program in the same process space,
without forking a separate child process.

10
node_modules/foreground-child/changelog.sh generated vendored Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
(
echo '# Changes'
echo ''
git log --first-parent --pretty=format:'%s' \
| grep -v '^update changelog' \
| grep -v 'beta' \
| perl -p -e 's/^((v?[0-9]+\.?)+)?$/\n## \1\n/g' \
| perl -p -e 's/^([^#\s].*)$/* \1/g'
)> CHANGELOG.md

133
node_modules/foreground-child/index.js generated vendored Normal file
View File

@@ -0,0 +1,133 @@
const signalExit = require('signal-exit')
/* istanbul ignore next */
const spawn = process.platform === 'win32' ? require('cross-spawn') : require('child_process').spawn
/**
* Normalizes the arguments passed to `foregroundChild`.
*
* See the signature of `foregroundChild` for the supported arguments.
*
* @param fgArgs Array of arguments passed to `foregroundChild`.
* @return Normalized arguments
* @internal
*/
function normalizeFgArgs(fgArgs) {
let program, args, cb;
let processArgsEnd = fgArgs.length;
const lastFgArg = fgArgs[fgArgs.length - 1];
if (typeof lastFgArg === "function") {
cb = lastFgArg;
processArgsEnd -= 1;
} else {
cb = (done) => done();
}
if (Array.isArray(fgArgs[0])) {
[program, ...args] = fgArgs[0];
} else {
program = fgArgs[0];
args = Array.isArray(fgArgs[1]) ? fgArgs[1] : fgArgs.slice(1, processArgsEnd);
}
return {program, args, cb};
}
/**
*
* Signatures:
* ```
* (program: string | string[], cb?: CloseHandler);
* (program: string, args: string[], cb?: CloseHandler);
* (program: string, ...args: string[], cb?: CloseHandler);
* ```
*/
function foregroundChild (...fgArgs) {
const {program, args, cb} = normalizeFgArgs(fgArgs);
const spawnOpts = { stdio: [0, 1, 2] }
if (process.send) {
spawnOpts.stdio.push('ipc')
}
const child = spawn(program, args, spawnOpts)
const unproxySignals = proxySignals(process, child)
process.on('exit', childHangup)
function childHangup () {
child.kill('SIGHUP')
}
child.on('close', (code, signal) => {
// Allow the callback to inspect the childs exit code and/or modify it.
process.exitCode = signal ? 128 + signal : code
let done = false;
const doneCB = () => {
if (done) {
return
}
done = true
unproxySignals()
process.removeListener('exit', childHangup)
if (signal) {
// If there is nothing else keeping the event loop alive,
// then there's a race between a graceful exit and getting
// the signal to this process. Put this timeout here to
// make sure we're still alive to get the signal, and thus
// exit with the intended signal code.
/* istanbul ignore next */
setTimeout(function () {}, 200)
process.kill(process.pid, signal)
} else {
process.exit(process.exitCode)
}
};
const result = cb(doneCB);
if (result && result.then) {
result.then(doneCB);
}
})
if (process.send) {
process.removeAllListeners('message')
child.on('message', (message, sendHandle) => {
process.send(message, sendHandle)
})
process.on('message', (message, sendHandle) => {
child.send(message, sendHandle)
})
}
return child
}
/**
* Starts forwarding signals to `child` through `parent`.
*
* @param parent Parent process.
* @param child Child Process.
* @return `unproxy` function to stop the forwarding.
* @internal
*/
function proxySignals (parent, child) {
const listeners = new Map()
for (const sig of signalExit.signals()) {
const listener = () => child.kill(sig)
listeners.set(sig, listener)
parent.on(sig, listener)
}
return function unproxySignals () {
for (const [sig, listener] of listeners) {
parent.removeListener(sig, listener)
}
}
}
module.exports = foregroundChild

40
node_modules/foreground-child/package.json generated vendored Normal file
View File

@@ -0,0 +1,40 @@
{
"name": "foreground-child",
"version": "2.0.0",
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.",
"main": "index.js",
"engines": {
"node": ">=8.0.0"
},
"dependencies": {
"cross-spawn": "^7.0.0",
"signal-exit": "^3.0.2"
},
"devDependencies": {
"tap": "^14.6.1"
},
"scripts": {
"test": "tap",
"changelog": "bash changelog.sh",
"postversion": "npm run changelog && git add CHANGELOG.md && git commit -m 'update changelog - '${npm_package_version}"
},
"tap": {
"jobs": 1
},
"repository": {
"type": "git",
"url": "git+https://github.com/tapjs/foreground-child.git"
},
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"license": "ISC",
"bugs": {
"url": "https://github.com/tapjs/foreground-child/issues"
},
"homepage": "https://github.com/tapjs/foreground-child#readme",
"directories": {
"test": "test"
},
"files": [
"index.js"
]
}