Deployed the page to Github Pages.

This commit is contained in:
Batuhan Berk Başoğlu 2024-11-03 21:30:09 -05:00
parent 1d79754e93
commit 2c89899458
Signed by: batuhan-basoglu
SSH key fingerprint: SHA256:kEsnuHX+qbwhxSAXPUQ4ox535wFHu/hIRaa53FzxRpo
62797 changed files with 6551425 additions and 15279 deletions

15
node_modules/foreground-child/LICENSE generated vendored Normal file
View file

@ -0,0 +1,15 @@
The ISC License
Copyright (c) 2015-2023 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.

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

@ -0,0 +1,128 @@
# 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. But it's
also generally useful any time you want one program to execute
another as if it's the "main" process, for example, if a program
takes a `--cmd` argument to execute in some way.
## USAGE
```js
import { foregroundChild } from 'foreground-child'
// hybrid module, this also works:
// const { foregroundChild } = require('foreground-child')
// cats out this file
const child = foregroundChild('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.
```
You can provide custom spawn options by passing an object after
the program and arguments:
```js
const child = foregroundChild(`cat ${__filename}`, { shell: true })
```
A callback can optionally be provided, if you want to perform an
action before your foreground-child exits:
```js
const child = foregroundChild('cat', [__filename], spawnOptions, () => {
doSomeActions()
})
```
The callback can return a Promise in order to perform
asynchronous actions. If the callback does not return a promise,
then it must complete its actions within a single JavaScript
tick.
```js
const child = foregroundChild('cat', [__filename], async () => {
await doSomeAsyncActions()
})
```
If the callback throws or rejects, then it will be unhandled, and
node will exit in error.
If the callback returns a string value, then that will be used as
the signal to exit the parent process. If it returns a number,
then that number will be used as the parent exit status code. If
it returns boolean `false`, then the parent process will not be
terminated. If it returns `undefined`, then it will exit with the
same signal/code as the child process.
## 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.
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, but
will not proxy the signal to the child process, because SIGKILL
cannot be caught. In order to address this, a special "watchdog"
child process is spawned which will send a SIGKILL to the child
process if it does not terminate within half a second after the
watchdog receives a SIGHUP due to its parent terminating.
On Windows, issuing a `process.kill(process.pid, signal)` with a
fatal termination signal may cause the process to exit with a `1`
status code rather than reporting the signal properly. This
module tries to do the right thing, but on Windows systems, you
may see that incorrect result. There is as far as I'm aware no
workaround for this.
## util: `foreground-child/proxy-signals`
If you just want to proxy the signals to a child process that the
main process receives, you can use the `proxy-signals` export
from this package.
```js
import { proxySignals } from 'foreground-child/proxy-signals'
const childProcess = spawn('command', ['some', 'args'])
proxySignals(childProcess)
```
Now, any fatal signal received by the current process will be
proxied to the child process.
It doesn't go in the other direction; ie, signals sent to the
child process will not affect the parent. For that, listen to the
child `exit` or `close` events, and handle them appropriately.
## util: `foreground-child/watchdog`
If you are spawning a child process, and want to ensure that it
isn't left dangling if the parent process exits, you can use the
watchdog utility exported by this module.
```js
import { watchdog } from 'foreground-child/watchdog'
const childProcess = spawn('command', ['some', 'args'])
const watchdogProcess = watchdog(childProcess)
// watchdogProcess is a reference to the process monitoring the
// parent and child. There's usually no reason to do anything
// with it, as it's silent and will terminate
// automatically when it's no longer needed.
```

View file

@ -0,0 +1,3 @@
/// <reference types="node" />
export declare const allSignals: NodeJS.Signals[];
//# sourceMappingURL=all-signals.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"all-signals.d.ts","sourceRoot":"","sources":["../../src/all-signals.ts"],"names":[],"mappings":";AACA,eAAO,MAAM,UAAU,kBASA,CAAA"}

View file

@ -0,0 +1,58 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.allSignals = void 0;
const node_constants_1 = __importDefault(require("node:constants"));
exports.allSignals =
// this is the full list of signals that Node will let us do anything with
Object.keys(node_constants_1.default).filter(k => k.startsWith('SIG') &&
// https://github.com/tapjs/signal-exit/issues/21
k !== 'SIGPROF' &&
// no sense trying to listen for SIGKILL, it's impossible
k !== 'SIGKILL');
// These are some obscure signals that are reported by kill -l
// on macOS, Linux, or Windows, but which don't have any mapping
// in Node.js. No sense trying if they're just going to throw
// every time on every platform.
//
// 'SIGEMT',
// 'SIGLOST',
// 'SIGPOLL',
// 'SIGRTMAX',
// 'SIGRTMAX-1',
// 'SIGRTMAX-10',
// 'SIGRTMAX-11',
// 'SIGRTMAX-12',
// 'SIGRTMAX-13',
// 'SIGRTMAX-14',
// 'SIGRTMAX-15',
// 'SIGRTMAX-2',
// 'SIGRTMAX-3',
// 'SIGRTMAX-4',
// 'SIGRTMAX-5',
// 'SIGRTMAX-6',
// 'SIGRTMAX-7',
// 'SIGRTMAX-8',
// 'SIGRTMAX-9',
// 'SIGRTMIN',
// 'SIGRTMIN+1',
// 'SIGRTMIN+10',
// 'SIGRTMIN+11',
// 'SIGRTMIN+12',
// 'SIGRTMIN+13',
// 'SIGRTMIN+14',
// 'SIGRTMIN+15',
// 'SIGRTMIN+16',
// 'SIGRTMIN+2',
// 'SIGRTMIN+3',
// 'SIGRTMIN+4',
// 'SIGRTMIN+5',
// 'SIGRTMIN+6',
// 'SIGRTMIN+7',
// 'SIGRTMIN+8',
// 'SIGRTMIN+9',
// 'SIGSTKFLT',
// 'SIGUNUSED',
//# sourceMappingURL=all-signals.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"all-signals.js","sourceRoot":"","sources":["../../src/all-signals.ts"],"names":[],"mappings":";;;;;;AAAA,oEAAsC;AACzB,QAAA,UAAU;AACrB,0EAA0E;AAC1E,MAAM,CAAC,IAAI,CAAC,wBAAS,CAAC,CAAC,MAAM,CAC3B,CAAC,CAAC,EAAE,CACF,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;IACnB,iDAAiD;IACjD,CAAC,KAAK,SAAS;IACf,yDAAyD;IACzD,CAAC,KAAK,SAAS,CACE,CAAA;AAEvB,8DAA8D;AAC9D,gEAAgE;AAChE,6DAA6D;AAC7D,gCAAgC;AAChC,EAAE;AACF,YAAY;AACZ,aAAa;AACb,aAAa;AACb,cAAc;AACd,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,cAAc;AACd,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,eAAe;AACf,eAAe","sourcesContent":["import constants from 'node:constants'\nexport const allSignals =\n // this is the full list of signals that Node will let us do anything with\n Object.keys(constants).filter(\n k =>\n k.startsWith('SIG') &&\n // https://github.com/tapjs/signal-exit/issues/21\n k !== 'SIGPROF' &&\n // no sense trying to listen for SIGKILL, it's impossible\n k !== 'SIGKILL',\n ) as NodeJS.Signals[]\n\n// These are some obscure signals that are reported by kill -l\n// on macOS, Linux, or Windows, but which don't have any mapping\n// in Node.js. No sense trying if they're just going to throw\n// every time on every platform.\n//\n// 'SIGEMT',\n// 'SIGLOST',\n// 'SIGPOLL',\n// 'SIGRTMAX',\n// 'SIGRTMAX-1',\n// 'SIGRTMAX-10',\n// 'SIGRTMAX-11',\n// 'SIGRTMAX-12',\n// 'SIGRTMAX-13',\n// 'SIGRTMAX-14',\n// 'SIGRTMAX-15',\n// 'SIGRTMAX-2',\n// 'SIGRTMAX-3',\n// 'SIGRTMAX-4',\n// 'SIGRTMAX-5',\n// 'SIGRTMAX-6',\n// 'SIGRTMAX-7',\n// 'SIGRTMAX-8',\n// 'SIGRTMAX-9',\n// 'SIGRTMIN',\n// 'SIGRTMIN+1',\n// 'SIGRTMIN+10',\n// 'SIGRTMIN+11',\n// 'SIGRTMIN+12',\n// 'SIGRTMIN+13',\n// 'SIGRTMIN+14',\n// 'SIGRTMIN+15',\n// 'SIGRTMIN+16',\n// 'SIGRTMIN+2',\n// 'SIGRTMIN+3',\n// 'SIGRTMIN+4',\n// 'SIGRTMIN+5',\n// 'SIGRTMIN+6',\n// 'SIGRTMIN+7',\n// 'SIGRTMIN+8',\n// 'SIGRTMIN+9',\n// 'SIGSTKFLT',\n// 'SIGUNUSED',\n"]}

65
node_modules/foreground-child/dist/commonjs/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,65 @@
/// <reference types="node" />
/// <reference types="node" />
import { ChildProcessByStdio, SpawnOptions, ChildProcess } from 'child_process';
/**
* The signature for the cleanup method.
*
* Arguments indicate the exit status of the child process.
*
* If a Promise is returned, then the process is not terminated
* until it resolves, and the resolution value is treated as the
* exit status (if a number) or signal exit (if a signal string).
*
* If `undefined` is returned, then no change is made, and the parent
* exits in the same way that the child exited.
*
* If boolean `false` is returned, then the parent's exit is canceled.
*
* If a number is returned, then the parent process exits with the number
* as its exitCode.
*
* If a signal string is returned, then the parent process is killed with
* the same signal that caused the child to exit.
*/
export type Cleanup = (code: number | null, signal: null | NodeJS.Signals, processInfo: {
watchdogPid?: ChildProcess['pid'];
}) => void | undefined | number | NodeJS.Signals | false | Promise<void | undefined | number | NodeJS.Signals | false>;
export type FgArgs = [program: string | [cmd: string, ...args: string[]], cleanup?: Cleanup] | [
program: [cmd: string, ...args: string[]],
opts?: SpawnOptions,
cleanup?: Cleanup
] | [program: string, cleanup?: Cleanup] | [program: string, opts?: SpawnOptions, cleanup?: Cleanup] | [program: string, args?: string[], cleanup?: Cleanup] | [
program: string,
args?: string[],
opts?: SpawnOptions,
cleanup?: Cleanup
];
/**
* Normalizes the arguments passed to `foregroundChild`.
*
* Exposed for testing.
*
* @internal
*/
export declare const normalizeFgArgs: (fgArgs: FgArgs) => [
program: string,
args: string[],
spawnOpts: SpawnOptions,
cleanup: Cleanup
];
/**
* Spawn the specified program as a "foreground" process, or at least as
* close as is possible given node's lack of exec-without-fork.
*
* Cleanup method may be used to modify or ignore the result of the child's
* exit code or signal. If cleanup returns undefined (or a Promise that
* resolves to undefined), then the parent will exit in the same way that
* the child did.
*
* Return boolean `false` to prevent the parent's exit entirely.
*/
export declare function foregroundChild(cmd: string | [cmd: string, ...args: string[]], cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
export declare function foregroundChild(program: string, args?: string[], cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
export declare function foregroundChild(program: string, spawnOpts?: SpawnOptions, cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
export declare function foregroundChild(program: string, args?: string[], spawnOpts?: SpawnOptions, cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,EACL,mBAAmB,EAInB,YAAY,EACZ,YAAY,EACb,MAAM,eAAe,CAAA;AAUtB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,EAC7B,WAAW,EAAE;IACX,WAAW,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;CAClC,KAEC,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,CAAC,OAAO,GACd,KAAK,GACL,OAAO,CAAC,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,CAAA;AAE/D,MAAM,MAAM,MAAM,GACd,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACvE;IACE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE,YAAY;IACnB,OAAO,CAAC,EAAE,OAAO;CAClB,GACD,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACpC,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACzD,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACrD;IACE,OAAO,EAAE,MAAM;IACf,IAAI,CAAC,EAAE,MAAM,EAAE;IACf,IAAI,CAAC,EAAE,YAAY;IACnB,OAAO,CAAC,EAAE,OAAO;CAClB,CAAA;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,KACb;IACD,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,MAAM,EAAE;IACd,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,OAAO;CAqBjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAC9C,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,YAAY,EACxB,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,YAAY,EACxB,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}

123
node_modules/foreground-child/dist/commonjs/index.js generated vendored Normal file
View file

@ -0,0 +1,123 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.foregroundChild = exports.normalizeFgArgs = void 0;
const child_process_1 = require("child_process");
const cross_spawn_1 = __importDefault(require("cross-spawn"));
const signal_exit_1 = require("signal-exit");
const proxy_signals_js_1 = require("./proxy-signals.js");
const watchdog_js_1 = require("./watchdog.js");
/* c8 ignore start */
const spawn = process?.platform === 'win32' ? cross_spawn_1.default : child_process_1.spawn;
/**
* Normalizes the arguments passed to `foregroundChild`.
*
* Exposed for testing.
*
* @internal
*/
const normalizeFgArgs = (fgArgs) => {
let [program, args = [], spawnOpts = {}, cleanup = () => { }] = fgArgs;
if (typeof args === 'function') {
cleanup = args;
spawnOpts = {};
args = [];
}
else if (!!args && typeof args === 'object' && !Array.isArray(args)) {
if (typeof spawnOpts === 'function')
cleanup = spawnOpts;
spawnOpts = args;
args = [];
}
else if (typeof spawnOpts === 'function') {
cleanup = spawnOpts;
spawnOpts = {};
}
if (Array.isArray(program)) {
const [pp, ...pa] = program;
program = pp;
args = pa;
}
return [program, args, { ...spawnOpts }, cleanup];
};
exports.normalizeFgArgs = normalizeFgArgs;
function foregroundChild(...fgArgs) {
const [program, args, spawnOpts, cleanup] = (0, exports.normalizeFgArgs)(fgArgs);
spawnOpts.stdio = [0, 1, 2];
if (process.send) {
spawnOpts.stdio.push('ipc');
}
const child = spawn(program, args, spawnOpts);
const childHangup = () => {
try {
child.kill('SIGHUP');
/* c8 ignore start */
}
catch (_) {
// SIGHUP is weird on windows
child.kill('SIGTERM');
}
/* c8 ignore stop */
};
const removeOnExit = (0, signal_exit_1.onExit)(childHangup);
(0, proxy_signals_js_1.proxySignals)(child);
const dog = (0, watchdog_js_1.watchdog)(child);
let done = false;
child.on('close', async (code, signal) => {
/* c8 ignore start */
if (done)
return;
/* c8 ignore stop */
done = true;
const result = cleanup(code, signal, {
watchdogPid: dog.pid,
});
const res = isPromise(result) ? await result : result;
removeOnExit();
if (res === false)
return;
else if (typeof res === 'string') {
signal = res;
code = null;
}
else if (typeof res === 'number') {
code = res;
signal = null;
}
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(() => { }, 2000);
try {
process.kill(process.pid, signal);
/* c8 ignore start */
}
catch (_) {
process.kill(process.pid, 'SIGTERM');
}
/* c8 ignore stop */
}
else {
process.exit(code || 0);
}
});
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;
}
exports.foregroundChild = foregroundChild;
const isPromise = (o) => !!o && typeof o === 'object' && typeof o.then === 'function';
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,3 @@
{
"type": "commonjs"
}

View file

@ -0,0 +1,7 @@
/// <reference types="node" />
import { type ChildProcess } from 'child_process';
/**
* Starts forwarding signals to `child` through `parent`.
*/
export declare const proxySignals: (child: ChildProcess) => () => void;
//# sourceMappingURL=proxy-signals.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"proxy-signals.d.ts","sourceRoot":"","sources":["../../src/proxy-signals.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,YAAY,eA4B/C,CAAA"}

View file

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.proxySignals = void 0;
const all_signals_js_1 = require("./all-signals.js");
/**
* Starts forwarding signals to `child` through `parent`.
*/
const proxySignals = (child) => {
const listeners = new Map();
for (const sig of all_signals_js_1.allSignals) {
const listener = () => {
// some signals can only be received, not sent
try {
child.kill(sig);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
};
try {
// if it's a signal this system doesn't recognize, skip it
process.on(sig, listener);
listeners.set(sig, listener);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
}
const unproxy = () => {
for (const [sig, listener] of listeners) {
process.removeListener(sig, listener);
}
};
child.on('exit', unproxy);
return unproxy;
};
exports.proxySignals = proxySignals;
//# sourceMappingURL=proxy-signals.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"proxy-signals.js","sourceRoot":"","sources":["../../src/proxy-signals.ts"],"names":[],"mappings":";;;AACA,qDAA6C;AAE7C;;GAEG;AACI,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE;IAClD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAA;IAE3B,KAAK,MAAM,GAAG,IAAI,2BAAU,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,8CAA8C;YAC9C,IAAI,CAAC;gBACH,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACf,qBAAqB;YACvB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;YACd,oBAAoB;QACtB,CAAC,CAAA;QACD,IAAI,CAAC;YACH,0DAA0D;YAC1D,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YACzB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YAC5B,qBAAqB;QACvB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;QACd,oBAAoB;IACtB,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;YACxC,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAA;IACD,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AA5BY,QAAA,YAAY,gBA4BxB","sourcesContent":["import { type ChildProcess } from 'child_process'\nimport { allSignals } from './all-signals.js'\n\n/**\n * Starts forwarding signals to `child` through `parent`.\n */\nexport const proxySignals = (child: ChildProcess) => {\n const listeners = new Map()\n\n for (const sig of allSignals) {\n const listener = () => {\n // some signals can only be received, not sent\n try {\n child.kill(sig)\n /* c8 ignore start */\n } catch (_) {}\n /* c8 ignore stop */\n }\n try {\n // if it's a signal this system doesn't recognize, skip it\n process.on(sig, listener)\n listeners.set(sig, listener)\n /* c8 ignore start */\n } catch (_) {}\n /* c8 ignore stop */\n }\n\n const unproxy = () => {\n for (const [sig, listener] of listeners) {\n process.removeListener(sig, listener)\n }\n }\n child.on('exit', unproxy)\n return unproxy\n}\n"]}

View file

@ -0,0 +1,11 @@
/// <reference types="node" />
import { ChildProcess } from 'child_process';
/**
* Pass in a ChildProcess, and this will spawn a watchdog process that
* will make sure it exits if the parent does, thus preventing any
* dangling detached zombie processes.
*
* If the child ends before the parent, then the watchdog will terminate.
*/
export declare const watchdog: (child: ChildProcess) => ChildProcess;
//# sourceMappingURL=watchdog.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"watchdog.d.ts","sourceRoot":"","sources":["../../src/watchdog.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,YAAY,EAAS,MAAM,eAAe,CAAA;AAyBnD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,UAAW,YAAY,iBAc3C,CAAA"}

View file

@ -0,0 +1,50 @@
"use strict";
// this spawns a child process that listens for SIGHUP when the
// parent process exits, and after 200ms, sends a SIGKILL to the
// child, in case it did not terminate.
Object.defineProperty(exports, "__esModule", { value: true });
exports.watchdog = void 0;
const child_process_1 = require("child_process");
const watchdogCode = String.raw `
const pid = parseInt(process.argv[1], 10)
process.title = 'node (foreground-child watchdog pid=' + pid + ')'
if (!isNaN(pid)) {
let barked = false
// keepalive
const interval = setInterval(() => {}, 60000)
const bark = () => {
clearInterval(interval)
if (barked) return
barked = true
process.removeListener('SIGHUP', bark)
setTimeout(() => {
try {
process.kill(pid, 'SIGKILL')
setTimeout(() => process.exit(), 200)
} catch (_) {}
}, 500)
})
process.on('SIGHUP', bark)
}
`;
/**
* Pass in a ChildProcess, and this will spawn a watchdog process that
* will make sure it exits if the parent does, thus preventing any
* dangling detached zombie processes.
*
* If the child ends before the parent, then the watchdog will terminate.
*/
const watchdog = (child) => {
let dogExited = false;
const dog = (0, child_process_1.spawn)(process.execPath, ['-e', watchdogCode, String(child.pid)], {
stdio: 'ignore',
});
dog.on('exit', () => (dogExited = true));
child.on('exit', () => {
if (!dogExited)
dog.kill('SIGKILL');
});
return dog;
};
exports.watchdog = watchdog;
//# sourceMappingURL=watchdog.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"watchdog.js","sourceRoot":"","sources":["../../src/watchdog.ts"],"names":[],"mappings":";AAAA,+DAA+D;AAC/D,gEAAgE;AAChE,uCAAuC;;;AAEvC,iDAAmD;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB9B,CAAA;AAED;;;;;;GAMG;AACI,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE;IAC9C,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,MAAM,GAAG,GAAG,IAAA,qBAAK,EACf,OAAO,CAAC,QAAQ,EAChB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACvC;QACE,KAAK,EAAE,QAAQ;KAChB,CACF,CAAA;IACD,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,IAAI,CAAC,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAdY,QAAA,QAAQ,YAcpB","sourcesContent":["// this spawns a child process that listens for SIGHUP when the\n// parent process exits, and after 200ms, sends a SIGKILL to the\n// child, in case it did not terminate.\n\nimport { ChildProcess, spawn } from 'child_process'\n\nconst watchdogCode = String.raw`\nconst pid = parseInt(process.argv[1], 10)\nprocess.title = 'node (foreground-child watchdog pid=' + pid + ')'\nif (!isNaN(pid)) {\n let barked = false\n // keepalive\n const interval = setInterval(() => {}, 60000)\n const bark = () => {\n clearInterval(interval)\n if (barked) return\n barked = true\n process.removeListener('SIGHUP', bark)\n setTimeout(() => {\n try {\n process.kill(pid, 'SIGKILL')\n setTimeout(() => process.exit(), 200)\n } catch (_) {}\n }, 500)\n })\n process.on('SIGHUP', bark)\n}\n`\n\n/**\n * Pass in a ChildProcess, and this will spawn a watchdog process that\n * will make sure it exits if the parent does, thus preventing any\n * dangling detached zombie processes.\n *\n * If the child ends before the parent, then the watchdog will terminate.\n */\nexport const watchdog = (child: ChildProcess) => {\n let dogExited = false\n const dog = spawn(\n process.execPath,\n ['-e', watchdogCode, String(child.pid)],\n {\n stdio: 'ignore',\n },\n )\n dog.on('exit', () => (dogExited = true))\n child.on('exit', () => {\n if (!dogExited) dog.kill('SIGKILL')\n })\n return dog\n}\n"]}

View file

@ -0,0 +1,3 @@
/// <reference types="node" resolution-mode="require"/>
export declare const allSignals: NodeJS.Signals[];
//# sourceMappingURL=all-signals.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"all-signals.d.ts","sourceRoot":"","sources":["../../src/all-signals.ts"],"names":[],"mappings":";AACA,eAAO,MAAM,UAAU,kBASA,CAAA"}

52
node_modules/foreground-child/dist/esm/all-signals.js generated vendored Normal file
View file

@ -0,0 +1,52 @@
import constants from 'node:constants';
export const allSignals =
// this is the full list of signals that Node will let us do anything with
Object.keys(constants).filter(k => k.startsWith('SIG') &&
// https://github.com/tapjs/signal-exit/issues/21
k !== 'SIGPROF' &&
// no sense trying to listen for SIGKILL, it's impossible
k !== 'SIGKILL');
// These are some obscure signals that are reported by kill -l
// on macOS, Linux, or Windows, but which don't have any mapping
// in Node.js. No sense trying if they're just going to throw
// every time on every platform.
//
// 'SIGEMT',
// 'SIGLOST',
// 'SIGPOLL',
// 'SIGRTMAX',
// 'SIGRTMAX-1',
// 'SIGRTMAX-10',
// 'SIGRTMAX-11',
// 'SIGRTMAX-12',
// 'SIGRTMAX-13',
// 'SIGRTMAX-14',
// 'SIGRTMAX-15',
// 'SIGRTMAX-2',
// 'SIGRTMAX-3',
// 'SIGRTMAX-4',
// 'SIGRTMAX-5',
// 'SIGRTMAX-6',
// 'SIGRTMAX-7',
// 'SIGRTMAX-8',
// 'SIGRTMAX-9',
// 'SIGRTMIN',
// 'SIGRTMIN+1',
// 'SIGRTMIN+10',
// 'SIGRTMIN+11',
// 'SIGRTMIN+12',
// 'SIGRTMIN+13',
// 'SIGRTMIN+14',
// 'SIGRTMIN+15',
// 'SIGRTMIN+16',
// 'SIGRTMIN+2',
// 'SIGRTMIN+3',
// 'SIGRTMIN+4',
// 'SIGRTMIN+5',
// 'SIGRTMIN+6',
// 'SIGRTMIN+7',
// 'SIGRTMIN+8',
// 'SIGRTMIN+9',
// 'SIGSTKFLT',
// 'SIGUNUSED',
//# sourceMappingURL=all-signals.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"all-signals.js","sourceRoot":"","sources":["../../src/all-signals.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAA;AACtC,MAAM,CAAC,MAAM,UAAU;AACrB,0EAA0E;AAC1E,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAC3B,CAAC,CAAC,EAAE,CACF,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;IACnB,iDAAiD;IACjD,CAAC,KAAK,SAAS;IACf,yDAAyD;IACzD,CAAC,KAAK,SAAS,CACE,CAAA;AAEvB,8DAA8D;AAC9D,gEAAgE;AAChE,6DAA6D;AAC7D,gCAAgC;AAChC,EAAE;AACF,YAAY;AACZ,aAAa;AACb,aAAa;AACb,cAAc;AACd,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,cAAc;AACd,gBAAgB;AAChB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,iBAAiB;AACjB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,gBAAgB;AAChB,eAAe;AACf,eAAe","sourcesContent":["import constants from 'node:constants'\nexport const allSignals =\n // this is the full list of signals that Node will let us do anything with\n Object.keys(constants).filter(\n k =>\n k.startsWith('SIG') &&\n // https://github.com/tapjs/signal-exit/issues/21\n k !== 'SIGPROF' &&\n // no sense trying to listen for SIGKILL, it's impossible\n k !== 'SIGKILL',\n ) as NodeJS.Signals[]\n\n// These are some obscure signals that are reported by kill -l\n// on macOS, Linux, or Windows, but which don't have any mapping\n// in Node.js. No sense trying if they're just going to throw\n// every time on every platform.\n//\n// 'SIGEMT',\n// 'SIGLOST',\n// 'SIGPOLL',\n// 'SIGRTMAX',\n// 'SIGRTMAX-1',\n// 'SIGRTMAX-10',\n// 'SIGRTMAX-11',\n// 'SIGRTMAX-12',\n// 'SIGRTMAX-13',\n// 'SIGRTMAX-14',\n// 'SIGRTMAX-15',\n// 'SIGRTMAX-2',\n// 'SIGRTMAX-3',\n// 'SIGRTMAX-4',\n// 'SIGRTMAX-5',\n// 'SIGRTMAX-6',\n// 'SIGRTMAX-7',\n// 'SIGRTMAX-8',\n// 'SIGRTMAX-9',\n// 'SIGRTMIN',\n// 'SIGRTMIN+1',\n// 'SIGRTMIN+10',\n// 'SIGRTMIN+11',\n// 'SIGRTMIN+12',\n// 'SIGRTMIN+13',\n// 'SIGRTMIN+14',\n// 'SIGRTMIN+15',\n// 'SIGRTMIN+16',\n// 'SIGRTMIN+2',\n// 'SIGRTMIN+3',\n// 'SIGRTMIN+4',\n// 'SIGRTMIN+5',\n// 'SIGRTMIN+6',\n// 'SIGRTMIN+7',\n// 'SIGRTMIN+8',\n// 'SIGRTMIN+9',\n// 'SIGSTKFLT',\n// 'SIGUNUSED',\n"]}

65
node_modules/foreground-child/dist/esm/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,65 @@
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import { ChildProcessByStdio, SpawnOptions, ChildProcess } from 'child_process';
/**
* The signature for the cleanup method.
*
* Arguments indicate the exit status of the child process.
*
* If a Promise is returned, then the process is not terminated
* until it resolves, and the resolution value is treated as the
* exit status (if a number) or signal exit (if a signal string).
*
* If `undefined` is returned, then no change is made, and the parent
* exits in the same way that the child exited.
*
* If boolean `false` is returned, then the parent's exit is canceled.
*
* If a number is returned, then the parent process exits with the number
* as its exitCode.
*
* If a signal string is returned, then the parent process is killed with
* the same signal that caused the child to exit.
*/
export type Cleanup = (code: number | null, signal: null | NodeJS.Signals, processInfo: {
watchdogPid?: ChildProcess['pid'];
}) => void | undefined | number | NodeJS.Signals | false | Promise<void | undefined | number | NodeJS.Signals | false>;
export type FgArgs = [program: string | [cmd: string, ...args: string[]], cleanup?: Cleanup] | [
program: [cmd: string, ...args: string[]],
opts?: SpawnOptions,
cleanup?: Cleanup
] | [program: string, cleanup?: Cleanup] | [program: string, opts?: SpawnOptions, cleanup?: Cleanup] | [program: string, args?: string[], cleanup?: Cleanup] | [
program: string,
args?: string[],
opts?: SpawnOptions,
cleanup?: Cleanup
];
/**
* Normalizes the arguments passed to `foregroundChild`.
*
* Exposed for testing.
*
* @internal
*/
export declare const normalizeFgArgs: (fgArgs: FgArgs) => [
program: string,
args: string[],
spawnOpts: SpawnOptions,
cleanup: Cleanup
];
/**
* Spawn the specified program as a "foreground" process, or at least as
* close as is possible given node's lack of exec-without-fork.
*
* Cleanup method may be used to modify or ignore the result of the child's
* exit code or signal. If cleanup returns undefined (or a Promise that
* resolves to undefined), then the parent will exit in the same way that
* the child did.
*
* Return boolean `false` to prevent the parent's exit entirely.
*/
export declare function foregroundChild(cmd: string | [cmd: string, ...args: string[]], cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
export declare function foregroundChild(program: string, args?: string[], cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
export declare function foregroundChild(program: string, spawnOpts?: SpawnOptions, cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
export declare function foregroundChild(program: string, args?: string[], spawnOpts?: SpawnOptions, cleanup?: Cleanup): ChildProcessByStdio<null, null, null>;
//# sourceMappingURL=index.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;AAAA,OAAO,EACL,mBAAmB,EAInB,YAAY,EACZ,YAAY,EACb,MAAM,eAAe,CAAA;AAUtB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,OAAO,GAAG,CACpB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC,OAAO,EAC7B,WAAW,EAAE;IACX,WAAW,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;CAClC,KAEC,IAAI,GACJ,SAAS,GACT,MAAM,GACN,MAAM,CAAC,OAAO,GACd,KAAK,GACL,OAAO,CAAC,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,CAAA;AAE/D,MAAM,MAAM,MAAM,GACd,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACvE;IACE,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;IACzC,IAAI,CAAC,EAAE,YAAY;IACnB,OAAO,CAAC,EAAE,OAAO;CAClB,GACD,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACpC,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACzD,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,GACrD;IACE,OAAO,EAAE,MAAM;IACf,IAAI,CAAC,EAAE,MAAM,EAAE;IACf,IAAI,CAAC,EAAE,YAAY;IACnB,OAAO,CAAC,EAAE,OAAO;CAClB,CAAA;AAEL;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,KACb;IACD,OAAO,EAAE,MAAM;IACf,IAAI,EAAE,MAAM,EAAE;IACd,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,OAAO;CAqBjB,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC,EAC9C,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,YAAY,EACxB,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACxC,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EAAE,EACf,SAAS,CAAC,EAAE,YAAY,EACxB,OAAO,CAAC,EAAE,OAAO,GAChB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}

115
node_modules/foreground-child/dist/esm/index.js generated vendored Normal file
View file

@ -0,0 +1,115 @@
import { spawn as nodeSpawn, } from 'child_process';
import crossSpawn from 'cross-spawn';
import { onExit } from 'signal-exit';
import { proxySignals } from './proxy-signals.js';
import { watchdog } from './watchdog.js';
/* c8 ignore start */
const spawn = process?.platform === 'win32' ? crossSpawn : nodeSpawn;
/**
* Normalizes the arguments passed to `foregroundChild`.
*
* Exposed for testing.
*
* @internal
*/
export const normalizeFgArgs = (fgArgs) => {
let [program, args = [], spawnOpts = {}, cleanup = () => { }] = fgArgs;
if (typeof args === 'function') {
cleanup = args;
spawnOpts = {};
args = [];
}
else if (!!args && typeof args === 'object' && !Array.isArray(args)) {
if (typeof spawnOpts === 'function')
cleanup = spawnOpts;
spawnOpts = args;
args = [];
}
else if (typeof spawnOpts === 'function') {
cleanup = spawnOpts;
spawnOpts = {};
}
if (Array.isArray(program)) {
const [pp, ...pa] = program;
program = pp;
args = pa;
}
return [program, args, { ...spawnOpts }, cleanup];
};
export function foregroundChild(...fgArgs) {
const [program, args, spawnOpts, cleanup] = normalizeFgArgs(fgArgs);
spawnOpts.stdio = [0, 1, 2];
if (process.send) {
spawnOpts.stdio.push('ipc');
}
const child = spawn(program, args, spawnOpts);
const childHangup = () => {
try {
child.kill('SIGHUP');
/* c8 ignore start */
}
catch (_) {
// SIGHUP is weird on windows
child.kill('SIGTERM');
}
/* c8 ignore stop */
};
const removeOnExit = onExit(childHangup);
proxySignals(child);
const dog = watchdog(child);
let done = false;
child.on('close', async (code, signal) => {
/* c8 ignore start */
if (done)
return;
/* c8 ignore stop */
done = true;
const result = cleanup(code, signal, {
watchdogPid: dog.pid,
});
const res = isPromise(result) ? await result : result;
removeOnExit();
if (res === false)
return;
else if (typeof res === 'string') {
signal = res;
code = null;
}
else if (typeof res === 'number') {
code = res;
signal = null;
}
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(() => { }, 2000);
try {
process.kill(process.pid, signal);
/* c8 ignore start */
}
catch (_) {
process.kill(process.pid, 'SIGTERM');
}
/* c8 ignore stop */
}
else {
process.exit(code || 0);
}
});
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;
}
const isPromise = (o) => !!o && typeof o === 'object' && typeof o.then === 'function';
//# sourceMappingURL=index.js.map

1
node_modules/foreground-child/dist/esm/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

3
node_modules/foreground-child/dist/esm/package.json generated vendored Normal file
View file

@ -0,0 +1,3 @@
{
"type": "module"
}

View file

@ -0,0 +1,7 @@
/// <reference types="node" resolution-mode="require"/>
import { type ChildProcess } from 'child_process';
/**
* Starts forwarding signals to `child` through `parent`.
*/
export declare const proxySignals: (child: ChildProcess) => () => void;
//# sourceMappingURL=proxy-signals.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"proxy-signals.d.ts","sourceRoot":"","sources":["../../src/proxy-signals.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,YAAY,eA4B/C,CAAA"}

View file

@ -0,0 +1,34 @@
import { allSignals } from './all-signals.js';
/**
* Starts forwarding signals to `child` through `parent`.
*/
export const proxySignals = (child) => {
const listeners = new Map();
for (const sig of allSignals) {
const listener = () => {
// some signals can only be received, not sent
try {
child.kill(sig);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
};
try {
// if it's a signal this system doesn't recognize, skip it
process.on(sig, listener);
listeners.set(sig, listener);
/* c8 ignore start */
}
catch (_) { }
/* c8 ignore stop */
}
const unproxy = () => {
for (const [sig, listener] of listeners) {
process.removeListener(sig, listener);
}
};
child.on('exit', unproxy);
return unproxy;
};
//# sourceMappingURL=proxy-signals.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"proxy-signals.js","sourceRoot":"","sources":["../../src/proxy-signals.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE;IAClD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAE,CAAA;IAE3B,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,8CAA8C;YAC9C,IAAI,CAAC;gBACH,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;gBACf,qBAAqB;YACvB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;YACd,oBAAoB;QACtB,CAAC,CAAA;QACD,IAAI,CAAC;YACH,0DAA0D;YAC1D,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YACzB,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;YAC5B,qBAAqB;QACvB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;QACd,oBAAoB;IACtB,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;YACxC,OAAO,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QACvC,CAAC;IACH,CAAC,CAAA;IACD,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACzB,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA","sourcesContent":["import { type ChildProcess } from 'child_process'\nimport { allSignals } from './all-signals.js'\n\n/**\n * Starts forwarding signals to `child` through `parent`.\n */\nexport const proxySignals = (child: ChildProcess) => {\n const listeners = new Map()\n\n for (const sig of allSignals) {\n const listener = () => {\n // some signals can only be received, not sent\n try {\n child.kill(sig)\n /* c8 ignore start */\n } catch (_) {}\n /* c8 ignore stop */\n }\n try {\n // if it's a signal this system doesn't recognize, skip it\n process.on(sig, listener)\n listeners.set(sig, listener)\n /* c8 ignore start */\n } catch (_) {}\n /* c8 ignore stop */\n }\n\n const unproxy = () => {\n for (const [sig, listener] of listeners) {\n process.removeListener(sig, listener)\n }\n }\n child.on('exit', unproxy)\n return unproxy\n}\n"]}

11
node_modules/foreground-child/dist/esm/watchdog.d.ts generated vendored Normal file
View file

@ -0,0 +1,11 @@
/// <reference types="node" resolution-mode="require"/>
import { ChildProcess } from 'child_process';
/**
* Pass in a ChildProcess, and this will spawn a watchdog process that
* will make sure it exits if the parent does, thus preventing any
* dangling detached zombie processes.
*
* If the child ends before the parent, then the watchdog will terminate.
*/
export declare const watchdog: (child: ChildProcess) => ChildProcess;
//# sourceMappingURL=watchdog.d.ts.map

View file

@ -0,0 +1 @@
{"version":3,"file":"watchdog.d.ts","sourceRoot":"","sources":["../../src/watchdog.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,YAAY,EAAS,MAAM,eAAe,CAAA;AAyBnD;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,UAAW,YAAY,iBAc3C,CAAA"}

46
node_modules/foreground-child/dist/esm/watchdog.js generated vendored Normal file
View file

@ -0,0 +1,46 @@
// this spawns a child process that listens for SIGHUP when the
// parent process exits, and after 200ms, sends a SIGKILL to the
// child, in case it did not terminate.
import { spawn } from 'child_process';
const watchdogCode = String.raw `
const pid = parseInt(process.argv[1], 10)
process.title = 'node (foreground-child watchdog pid=' + pid + ')'
if (!isNaN(pid)) {
let barked = false
// keepalive
const interval = setInterval(() => {}, 60000)
const bark = () => {
clearInterval(interval)
if (barked) return
barked = true
process.removeListener('SIGHUP', bark)
setTimeout(() => {
try {
process.kill(pid, 'SIGKILL')
setTimeout(() => process.exit(), 200)
} catch (_) {}
}, 500)
})
process.on('SIGHUP', bark)
}
`;
/**
* Pass in a ChildProcess, and this will spawn a watchdog process that
* will make sure it exits if the parent does, thus preventing any
* dangling detached zombie processes.
*
* If the child ends before the parent, then the watchdog will terminate.
*/
export const watchdog = (child) => {
let dogExited = false;
const dog = spawn(process.execPath, ['-e', watchdogCode, String(child.pid)], {
stdio: 'ignore',
});
dog.on('exit', () => (dogExited = true));
child.on('exit', () => {
if (!dogExited)
dog.kill('SIGKILL');
});
return dog;
};
//# sourceMappingURL=watchdog.js.map

View file

@ -0,0 +1 @@
{"version":3,"file":"watchdog.js","sourceRoot":"","sources":["../../src/watchdog.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,gEAAgE;AAChE,uCAAuC;AAEvC,OAAO,EAAgB,KAAK,EAAE,MAAM,eAAe,CAAA;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;CAqB9B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE;IAC9C,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,MAAM,GAAG,GAAG,KAAK,CACf,OAAO,CAAC,QAAQ,EAChB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EACvC;QACE,KAAK,EAAE,QAAQ;KAChB,CACF,CAAA;IACD,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAA;IACxC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,IAAI,CAAC,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["// this spawns a child process that listens for SIGHUP when the\n// parent process exits, and after 200ms, sends a SIGKILL to the\n// child, in case it did not terminate.\n\nimport { ChildProcess, spawn } from 'child_process'\n\nconst watchdogCode = String.raw`\nconst pid = parseInt(process.argv[1], 10)\nprocess.title = 'node (foreground-child watchdog pid=' + pid + ')'\nif (!isNaN(pid)) {\n let barked = false\n // keepalive\n const interval = setInterval(() => {}, 60000)\n const bark = () => {\n clearInterval(interval)\n if (barked) return\n barked = true\n process.removeListener('SIGHUP', bark)\n setTimeout(() => {\n try {\n process.kill(pid, 'SIGKILL')\n setTimeout(() => process.exit(), 200)\n } catch (_) {}\n }, 500)\n })\n process.on('SIGHUP', bark)\n}\n`\n\n/**\n * Pass in a ChildProcess, and this will spawn a watchdog process that\n * will make sure it exits if the parent does, thus preventing any\n * dangling detached zombie processes.\n *\n * If the child ends before the parent, then the watchdog will terminate.\n */\nexport const watchdog = (child: ChildProcess) => {\n let dogExited = false\n const dog = spawn(\n process.execPath,\n ['-e', watchdogCode, String(child.pid)],\n {\n stdio: 'ignore',\n },\n )\n dog.on('exit', () => (dogExited = true))\n child.on('exit', () => {\n if (!dogExited) dog.kill('SIGKILL')\n })\n return dog\n}\n"]}

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

@ -0,0 +1,111 @@
{
"name": "foreground-child",
"version": "3.3.0",
"description": "Run a child as if it's the foreground process. Give it stdio. Exit when it exits.",
"main": "./dist/commonjs/index.js",
"types": "./dist/commonjs/index.d.ts",
"exports": {
"./watchdog": {
"import": {
"source": "./src/watchdog.ts",
"types": "./dist/esm/watchdog.d.ts",
"default": "./dist/esm/watchdog.js"
},
"require": {
"source": "./src/watchdog.ts",
"types": "./dist/commonjs/watchdog.d.ts",
"default": "./dist/commonjs/watchdog.js"
}
},
"./proxy-signals": {
"import": {
"source": "./src/proxy-signals.ts",
"types": "./dist/esm/proxy-signals.d.ts",
"default": "./dist/esm/proxy-signals.js"
},
"require": {
"source": "./src/proxy-signals.ts",
"types": "./dist/commonjs/proxy-signals.d.ts",
"default": "./dist/commonjs/proxy-signals.js"
}
},
"./package.json": "./package.json",
".": {
"import": {
"source": "./src/index.ts",
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"source": "./src/index.ts",
"types": "./dist/commonjs/index.d.ts",
"default": "./dist/commonjs/index.js"
}
}
},
"files": [
"dist"
],
"engines": {
"node": ">=14"
},
"dependencies": {
"cross-spawn": "^7.0.0",
"signal-exit": "^4.0.1"
},
"scripts": {
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"prepare": "tshy",
"pretest": "npm run prepare",
"presnap": "npm run prepare",
"test": "tap",
"snap": "tap",
"format": "prettier --write . --log-level warn",
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
},
"prettier": {
"experimentalTernaries": true,
"semi": false,
"printWidth": 75,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"jsxSingleQuote": false,
"bracketSameLine": true,
"arrowParens": "avoid",
"endOfLine": "lf"
},
"tap": {
"typecheck": true
},
"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",
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/node": "^18.15.11",
"@types/tap": "^15.0.8",
"prettier": "^3.3.2",
"tap": "^19.2.5",
"tshy": "^1.15.1",
"typedoc": "^0.24.2",
"typescript": "^5.0.2"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
},
"tshy": {
"exports": {
"./watchdog": "./src/watchdog.ts",
"./proxy-signals": "./src/proxy-signals.ts",
"./package.json": "./package.json",
".": "./src/index.ts"
}
},
"type": "module"
}