@tapjs/processinfo 2.2.3 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/cjs/child_process.js +2 -2
- package/dist/cjs/child_process.js.map +1 -1
- package/dist/cjs/get-process-info.d.ts.map +1 -1
- package/dist/cjs/get-process-info.js +8 -2
- package/dist/cjs/get-process-info.js.map +1 -1
- package/dist/cjs/line-lengths.d.ts +3 -0
- package/dist/cjs/line-lengths.d.ts.map +1 -0
- package/dist/cjs/line-lengths.js +32 -0
- package/dist/cjs/line-lengths.js.map +1 -0
- package/dist/cjs/register-cjs.d.ts.map +1 -1
- package/dist/cjs/register-cjs.js +6 -1
- package/dist/cjs/register-cjs.js.map +1 -1
- package/dist/cjs/register-coverage.d.ts.map +1 -1
- package/dist/cjs/register-coverage.js +6 -12
- package/dist/cjs/register-coverage.js.map +1 -1
- package/dist/cjs/register-env.d.ts.map +1 -1
- package/dist/cjs/register-env.js +7 -5
- package/dist/cjs/register-env.js.map +1 -1
- package/dist/mjs/esm.d.mts.map +1 -1
- package/dist/mjs/esm.mjs +23 -12
- package/dist/mjs/esm.mjs.map +1 -1
- package/dist/mjs/get-process-info.d.ts.map +1 -1
- package/dist/mjs/get-process-info.js +8 -2
- package/dist/mjs/get-process-info.js.map +1 -1
- package/dist/mjs/line-lengths.d.ts +3 -0
- package/dist/mjs/line-lengths.d.ts.map +1 -0
- package/dist/mjs/line-lengths.js +27 -0
- package/dist/mjs/line-lengths.js.map +1 -0
- package/dist/mjs/register-cjs.d.ts.map +1 -1
- package/dist/mjs/register-cjs.js +6 -1
- package/dist/mjs/register-cjs.js.map +1 -1
- package/dist/mjs/register-coverage.d.ts.map +1 -1
- package/dist/mjs/register-coverage.js +7 -13
- package/dist/mjs/register-coverage.js.map +1 -1
- package/dist/mjs/register-env.d.ts.map +1 -1
- package/dist/mjs/register-env.js +7 -5
- package/dist/mjs/register-env.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -51,6 +51,14 @@ If you just use the normal `spawn`/`exec` methods from the Node.js
|
|
|
51
51
|
`child_process` module, then the relevant environment variables will still
|
|
52
52
|
be tracked, unless explicitly set to `''` or some other value.
|
|
53
53
|
|
|
54
|
+
### Important
|
|
55
|
+
|
|
56
|
+
In order to properly track `lineLengths` (required for coverage
|
|
57
|
+
reporting on source mapped files), `@tapjs/processinfo` must be
|
|
58
|
+
the **last** loader specified on the command line, so that it can
|
|
59
|
+
get access to the transpiled source that Node.js actually
|
|
60
|
+
executes.
|
|
61
|
+
|
|
54
62
|
### Interacting with Process Info
|
|
55
63
|
|
|
56
64
|
To load the process info data, use the exported `ProcessInfo` class.
|
|
@@ -49,7 +49,7 @@ exports.exec = exec;
|
|
|
49
49
|
exec.__promisify__ = __promisify__;
|
|
50
50
|
Object.assign(exec, { [promisify]: __promisify__ });
|
|
51
51
|
/* c8 ignore start */
|
|
52
|
-
})(exec
|
|
52
|
+
})(exec || (exports.exec = exec = {}));
|
|
53
53
|
function execSync(cmd, options) {
|
|
54
54
|
return (0, child_process_1.execSync)(cmd, (0, spawn_opts_js_1.spawnOpts)(options || {}, (0, get_exclude_js_1.getExclude)(k)));
|
|
55
55
|
}
|
|
@@ -87,7 +87,7 @@ exports.execFile = execFile;
|
|
|
87
87
|
execFile.__promisify__ = __promisify__;
|
|
88
88
|
Object.assign(execFile, { [promisify]: __promisify__ });
|
|
89
89
|
/* c8 ignore start */
|
|
90
|
-
})(execFile
|
|
90
|
+
})(execFile || (exports.execFile = execFile = {}));
|
|
91
91
|
function execFileSync(file, args, options) {
|
|
92
92
|
if (args &&
|
|
93
93
|
typeof args === 'object' &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"child_process.js","sourceRoot":"","sources":["../../lib/child_process.ts"],"names":[],"mappings":";;;AAAA,0EAA0E;AAC1E,iEAAiE;AACjE,iDAmCsB;AAGtB,qDAA6C;AAC7C,mDAA2D;AAE3D,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zD,OAGyD;IAEzD,IACE,IAAI;QACJ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,CAIR,IAAI,CAAC,EACP;QACA,OAAO,GAAG,IAAI,CAAA;QACd,IAAI,GAAG,EAAE,CAAA;KACV;IACD,OAAO,IAAA,4BAAc,EACnB,IAAI,EACJ,IAAI,IAAI,EAAE,EACV,IAAA,yBAAS,EAAC,OAAO,IAAI,EAAE,EAAE,IAAA,2BAAU,EAAC,CAAC,CAAC,CAAC,CACxC,CAAA;AACH,CAAC;AA7BD,oCA6BC;AAWD,SAAgB,IAAI,CAClB,UAAkB,EAClB,IAA0C,EAC1C,OAAqC;IAErC,IAAI,UAAU,CAAc,IAAI,CAAC,EAAE;QACjC,OAAO,GAAG,IAAI,CAAA;QACd,IAAI,GAAG,EAAE,CAAA;KACV;IACD,OAAO,IAAA,oBAAM,EAAC,UAAU,EAAE,IAAI,EAAE,IAAA,yBAAS,EAAC,OAAO,IAAI,EAAE,EAAE,IAAA,2BAAU,EAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC;AAVD,oBAUC","sourcesContent":["// This wraps all of the various spawn methods such that externalID can be\n// set in the options, and ensuring that the proper envs get set.\nimport {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n exec as cpExec,\n ExecException,\n execFile as cpExecFile,\n ExecFileException,\n ExecFileOptions,\n ExecFileOptionsWithBufferEncoding,\n ExecFileOptionsWithOtherEncoding,\n ExecFileOptionsWithStringEncoding,\n execFileSync as cpExecFileSync,\n ExecFileSyncOptions,\n ExecFileSyncOptionsWithBufferEncoding,\n ExecFileSyncOptionsWithStringEncoding,\n ExecOptions,\n execSync as cpExecSync,\n ExecSyncOptions,\n ExecSyncOptionsWithBufferEncoding,\n ExecSyncOptionsWithStringEncoding,\n fork as cpFork,\n ForkOptions,\n PromiseWithChild,\n spawn as cpSpawn,\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n spawnSync as cpSpawnSync,\n SpawnSyncOptions,\n SpawnSyncOptionsWithBufferEncoding,\n SpawnSyncOptionsWithStringEncoding,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'child_process'\nimport type { ObjectEncodingOptions } from 'fs'\nimport type { Readable, Writable } from 'stream'\nimport { getExclude } from './get-exclude.js'\nimport { spawnOpts, WithExternalID } from './spawn-opts.js'\n\nconst promisify = Symbol.for('nodejs.util.promisify.custom')\n\n// pull the old __promisify__ out of node's declared namespaces\ntype CP<T extends { __promisify__: any }> = T & {\n [promisify]: T['__promisify__']\n}\ntype OldCP = { __promisify__: (...a: any) => any }\nconst customPromisify = <T extends OldCP>(e: T) =>\n // the node types list it as __promisify__ but it's actually the symbol\n /* c8 ignore start */\n (e as CP<T>)[promisify] || e.__promisify__\n/* c8 ignore stop */\n\nconst k = '_TAPJS_PROCESSINFO_EXCLUDE_'\n\n// coercion function when we know it's an array or something else\nconst isNotArray = <T extends { [k: string]: any }>(o: any): o is T =>\n !!o && typeof o === 'object' && !Array.isArray(o)\n\nexport function spawn(\n command: string,\n options?: WithExternalID<SpawnOptionsWithoutStdio>\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<SpawnOptions>\n): ChildProcess\nexport function spawn(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnOptionsWithoutStdio\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptions\n): ChildProcess\n\nexport function spawn(\n cmd: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >,\n options?:\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >\n): ChildProcess | ChildProcessWithoutNullStreams {\n if (isNotArray<SpawnOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawn(cmd, args || [], spawnOpts(options || {}, getExclude(k)))\n}\n\nexport function spawnSync(command: string): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\n\nexport function spawnSync(\n cmd: string,\n args?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n | ReadonlyArray<string>,\n options?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n) {\n if (isNotArray<SpawnSyncOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawnSync(\n cmd,\n args || [],\n spawnOpts(options || {}, getExclude(k))\n )\n}\n\nexport type ExecArgs =\n | [\n command: string,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<ExecOptions>,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | undefined\n | null,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\nexport function exec(...args: ExecArgs): ChildProcess {\n const [cmd, options, callback] = args\n if (typeof options === 'function') {\n return cpExec(cmd, spawnOpts<ExecOptions>({}, getExclude(k)), options)\n } else if (!options) {\n return cpExec(\n cmd,\n spawnOpts<ExecOptions>({}, getExclude(k)),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n }\n\n return cpExec(\n cmd,\n spawnOpts(options, getExclude(k)),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n}\n\nexport namespace exec {\n export function __promisify__(command: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<ExecOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options?: WithExternalID<ObjectEncodingOptions & ExecOptions> | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n command: string,\n options?:\n | WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n | WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n | WithExternalID<ExecOptions>\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n return customPromisify(cpExec)(\n command,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n\n Object.assign(exec, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execSync(command: string): Buffer\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithStringEncoding>\n): string\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execSync(\n command: string,\n options?: WithExternalID<ExecSyncOptions>\n): string | Buffer\nexport function execSync(\n cmd: string,\n options?:\n | WithExternalID<ExecSyncOptions>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n | WithExternalID<ExecSyncOptionsWithStringEncoding>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): string | Buffer {\n return cpExecSync(\n cmd,\n spawnOpts<ExecSyncOptions>(options || {}, getExclude(k))\n )\n}\n\nexport type ExecFileArgs =\n | []\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [args?: ReadonlyArray<string> | null]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\nexport function execFile(\n file: string,\n ...execFileArgs: ExecFileArgs\n): ChildProcess {\n let args = []\n let options: WithExternalID<ObjectEncodingOptions & ExecFileOptions> = {}\n let callback: ((...a: any) => any) | undefined = undefined\n for (const arg of execFileArgs) {\n if (Array.isArray(arg)) {\n args = arg\n } else if (\n arg &&\n typeof arg === 'object' &&\n isNotArray<WithExternalID<ObjectEncodingOptions & ExecFileOptions>>(\n arg\n )\n ) {\n options = arg\n } else if (typeof arg === 'function') {\n callback = arg\n }\n }\n return cpExecFile(\n file,\n args,\n spawnOpts(options, getExclude(k)),\n callback\n )\n}\n\nexport namespace execFile {\n export function __promisify__(file: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args?:\n | ReadonlyArray<string>\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>,\n options?:\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n if (\n !!args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n >(args)\n ) {\n options = args\n args = []\n }\n return customPromisify(cpExecFile)(\n file,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n Object.assign(execFile, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execFileSync(file: string): Buffer\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>\n): Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>,\n options?:\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): string | Buffer {\n if (\n args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n >(args)\n ) {\n options = args\n args = []\n }\n return cpExecFileSync(\n file,\n args || [],\n spawnOpts(options || {}, getExclude(k))\n )\n}\n\nexport function fork(\n modulePath: string,\n options?: ForkOptions\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ForkOptions | ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess {\n if (isNotArray<ForkOptions>(args)) {\n options = args\n args = []\n }\n return cpFork(modulePath, args, spawnOpts(options || {}, getExclude(k)))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"child_process.js","sourceRoot":"","sources":["../../lib/child_process.ts"],"names":[],"mappings":";;;AAAA,0EAA0E;AAC1E,iEAAiE;AACjE,iDAmCsB;AAGtB,qDAA6C;AAC7C,mDAA2D;AAE3D,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;AAO5D,MAAM,eAAe,GAAG,CAAkB,CAAI,EAAE,EAAE;AAChD,uEAAuE;AACvE,qBAAqB;AACpB,CAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,aAAa,CAAA;AAC5C,oBAAoB;AAEpB,MAAM,CAAC,GAAG,6BAA6B,CAAA;AAEvC,iEAAiE;AACjE,MAAM,UAAU,GAAG,CAA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A7BD,oCA6BC;AAWD,SAAgB,IAAI,CAClB,UAAkB,EAClB,IAA0C,EAC1C,OAAqC;IAErC,IAAI,UAAU,CAAc,IAAI,CAAC,EAAE;QACjC,OAAO,GAAG,IAAI,CAAA;QACd,IAAI,GAAG,EAAE,CAAA;KACV;IACD,OAAO,IAAA,oBAAM,EAAC,UAAU,EAAE,IAAI,EAAE,IAAA,yBAAS,EAAC,OAAO,IAAI,EAAE,EAAE,IAAA,2BAAU,EAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC;AAVD,oBAUC","sourcesContent":["// This wraps all of the various spawn methods such that externalID can be\n// set in the options, and ensuring that the proper envs get set.\nimport {\n ChildProcess,\n ChildProcessByStdio,\n ChildProcessWithoutNullStreams,\n exec as cpExec,\n ExecException,\n execFile as cpExecFile,\n ExecFileException,\n ExecFileOptions,\n ExecFileOptionsWithBufferEncoding,\n ExecFileOptionsWithOtherEncoding,\n ExecFileOptionsWithStringEncoding,\n execFileSync as cpExecFileSync,\n ExecFileSyncOptions,\n ExecFileSyncOptionsWithBufferEncoding,\n ExecFileSyncOptionsWithStringEncoding,\n ExecOptions,\n execSync as cpExecSync,\n ExecSyncOptions,\n ExecSyncOptionsWithBufferEncoding,\n ExecSyncOptionsWithStringEncoding,\n fork as cpFork,\n ForkOptions,\n PromiseWithChild,\n spawn as cpSpawn,\n SpawnOptions,\n SpawnOptionsWithoutStdio,\n SpawnOptionsWithStdioTuple,\n spawnSync as cpSpawnSync,\n SpawnSyncOptions,\n SpawnSyncOptionsWithBufferEncoding,\n SpawnSyncOptionsWithStringEncoding,\n SpawnSyncReturns,\n StdioNull,\n StdioPipe,\n} from 'child_process'\nimport type { ObjectEncodingOptions } from 'fs'\nimport type { Readable, Writable } from 'stream'\nimport { getExclude } from './get-exclude.js'\nimport { spawnOpts, WithExternalID } from './spawn-opts.js'\n\nconst promisify = Symbol.for('nodejs.util.promisify.custom')\n\n// pull the old __promisify__ out of node's declared namespaces\ntype CP<T extends { __promisify__: any }> = T & {\n [promisify]: T['__promisify__']\n}\ntype OldCP = { __promisify__: (...a: any) => any }\nconst customPromisify = <T extends OldCP>(e: T) =>\n // the node types list it as __promisify__ but it's actually the symbol\n /* c8 ignore start */\n (e as CP<T>)[promisify] || e.__promisify__\n/* c8 ignore stop */\n\nconst k = '_TAPJS_PROCESSINFO_EXCLUDE_'\n\n// coercion function when we know it's an array or something else\nconst isNotArray = <T extends { [k: string]: any }>(o: any): o is T =>\n !!o && typeof o === 'object' && !Array.isArray(o)\n\nexport function spawn(\n command: string,\n options?: WithExternalID<SpawnOptionsWithoutStdio>\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n >\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n >\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n >\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n options: WithExternalID<\n SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n >\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n options: WithExternalID<SpawnOptions>\n): ChildProcess\nexport function spawn(\n command: string,\n args?: ReadonlyArray<string>,\n options?: SpawnOptionsWithoutStdio\n): ChildProcessWithoutNullStreams\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioPipe>\n): ChildProcessByStdio<Writable, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioPipe, StdioNull>\n): ChildProcessByStdio<Writable, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioPipe>\n): ChildProcessByStdio<Writable, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioPipe>\n): ChildProcessByStdio<null, Readable, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioPipe, StdioNull, StdioNull>\n): ChildProcessByStdio<Writable, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioPipe, StdioNull>\n): ChildProcessByStdio<null, Readable, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioPipe>\n): ChildProcessByStdio<null, null, Readable>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptionsWithStdioTuple<StdioNull, StdioNull, StdioNull>\n): ChildProcessByStdio<null, null, null>\nexport function spawn(\n command: string,\n args: ReadonlyArray<string>,\n options: SpawnOptions\n): ChildProcess\n\nexport function spawn(\n cmd: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >,\n options?:\n | WithExternalID<SpawnOptions>\n | WithExternalID<SpawnOptionsWithoutStdio>\n | WithExternalID<\n SpawnOptionsWithStdioTuple<\n StdioNull | StdioPipe,\n StdioNull | StdioPipe,\n StdioNull | StdioPipe\n >\n >\n): ChildProcess | ChildProcessWithoutNullStreams {\n if (isNotArray<SpawnOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawn(cmd, args || [], spawnOpts(options || {}, getExclude(k)))\n}\n\nexport function spawnSync(command: string): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithStringEncoding>\n): SpawnSyncReturns<string>\nexport function spawnSync(\n command: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n): SpawnSyncReturns<Buffer>\nexport function spawnSync(\n command: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<SpawnSyncOptions>\n): SpawnSyncReturns<string | Buffer>\n\nexport function spawnSync(\n cmd: string,\n args?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n | ReadonlyArray<string>,\n options?:\n | WithExternalID<SpawnSyncOptionsWithStringEncoding>\n | WithExternalID<SpawnSyncOptionsWithBufferEncoding>\n | WithExternalID<SpawnSyncOptions>\n) {\n if (isNotArray<SpawnSyncOptions>(args)) {\n options = args\n args = []\n }\n return cpSpawnSync(\n cmd,\n args || [],\n spawnOpts(options || {}, getExclude(k))\n )\n}\n\nexport type ExecArgs =\n | [\n command: string,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n command: string,\n options: WithExternalID<ExecOptions>,\n callback?: (\n error: ExecException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n command: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | undefined\n | null,\n callback?: (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\nexport function exec(...args: ExecArgs): ChildProcess {\n const [cmd, options, callback] = args\n if (typeof options === 'function') {\n return cpExec(cmd, spawnOpts<ExecOptions>({}, getExclude(k)), options)\n } else if (!options) {\n return cpExec(\n cmd,\n spawnOpts<ExecOptions>({}, getExclude(k)),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n }\n\n return cpExec(\n cmd,\n spawnOpts(options, getExclude(k)),\n callback as (\n error: ExecException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n )\n}\n\nexport namespace exec {\n export function __promisify__(command: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options: WithExternalID<ExecOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n command: string,\n options?: WithExternalID<ObjectEncodingOptions & ExecOptions> | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n command: string,\n options?:\n | WithExternalID<\n {\n encoding: 'buffer' | null\n } & ExecOptions\n >\n | WithExternalID<\n {\n encoding: BufferEncoding\n } & ExecOptions\n >\n | WithExternalID<ExecOptions>\n | WithExternalID<ObjectEncodingOptions & ExecOptions>\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n return customPromisify(cpExec)(\n command,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n\n Object.assign(exec, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execSync(command: string): Buffer\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithStringEncoding>\n): string\nexport function execSync(\n command: string,\n options: WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execSync(\n command: string,\n options?: WithExternalID<ExecSyncOptions>\n): string | Buffer\nexport function execSync(\n cmd: string,\n options?:\n | WithExternalID<ExecSyncOptions>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n | WithExternalID<ExecSyncOptionsWithStringEncoding>\n | WithExternalID<ExecSyncOptionsWithBufferEncoding>\n): string | Buffer {\n return cpExecSync(\n cmd,\n spawnOpts<ExecSyncOptions>(options || {}, getExclude(k))\n )\n}\n\nexport type ExecFileArgs =\n | []\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [args?: ReadonlyArray<string> | null]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ]\n | [\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: Buffer,\n stderr: Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>,\n callback: (\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void\n ]\n | [\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>,\n callback: (\n error: ExecFileException | null,\n stdout: string,\n stderr: string\n ) => void\n ]\n | [\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\n | [\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null,\n callback:\n | ((\n error: ExecFileException | null,\n stdout: string | Buffer,\n stderr: string | Buffer\n ) => void)\n | undefined\n | null\n ]\nexport function execFile(\n file: string,\n ...execFileArgs: ExecFileArgs\n): ChildProcess {\n let args = []\n let options: WithExternalID<ObjectEncodingOptions & ExecFileOptions> = {}\n let callback: ((...a: any) => any) | undefined = undefined\n for (const arg of execFileArgs) {\n if (Array.isArray(arg)) {\n args = arg\n } else if (\n arg &&\n typeof arg === 'object' &&\n isNotArray<WithExternalID<ObjectEncodingOptions & ExecFileOptions>>(\n arg\n )\n ) {\n options = arg\n } else if (typeof arg === 'function') {\n callback = arg\n }\n }\n return cpExecFile(\n file,\n args,\n spawnOpts(options, getExclude(k)),\n callback\n )\n}\n\nexport namespace execFile {\n export function __promisify__(file: string): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithBufferEncoding>\n ): PromiseWithChild<{\n stdout: Buffer\n stderr: Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithStringEncoding>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptionsWithOtherEncoding>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options: WithExternalID<ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string\n stderr: string\n }>\n export function __promisify__(\n file: string,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args: ReadonlyArray<string> | undefined | null,\n options:\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | undefined\n | null\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }>\n export function __promisify__(\n file: string,\n args?:\n | ReadonlyArray<string>\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>,\n options?:\n | undefined\n | null\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n ): PromiseWithChild<{\n stdout: string | Buffer\n stderr: string | Buffer\n }> {\n if (\n !!args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileOptionsWithBufferEncoding>\n | WithExternalID<ExecFileOptionsWithStringEncoding>\n | WithExternalID<ExecFileOptionsWithOtherEncoding>\n | WithExternalID<ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n | WithExternalID<ObjectEncodingOptions & ExecFileOptions>\n >(args)\n ) {\n options = args\n args = []\n }\n return customPromisify(cpExecFile)(\n file,\n spawnOpts(options || {}, getExclude(k))\n )\n }\n Object.assign(execFile, { [promisify]: __promisify__ })\n /* c8 ignore start */\n}\n/* c8 ignore stop */\n\nexport function execFileSync(file: string): Buffer\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>\n): Buffer\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n): string\nexport function execFileSync(\n file: string,\n args: ReadonlyArray<string>,\n options: WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): Buffer\nexport function execFileSync(\n file: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ExecFileSyncOptions>\n): string | Buffer\nexport function execFileSync(\n file: string,\n args?:\n | ReadonlyArray<string>\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>,\n options?:\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n): string | Buffer {\n if (\n args &&\n typeof args === 'object' &&\n isNotArray<\n | WithExternalID<ExecFileSyncOptions>\n | WithExternalID<ExecFileSyncOptionsWithStringEncoding>\n | WithExternalID<ExecFileSyncOptionsWithBufferEncoding>\n >(args)\n ) {\n options = args\n args = []\n }\n return cpExecFileSync(\n file,\n args || [],\n spawnOpts(options || {}, getExclude(k))\n )\n}\n\nexport function fork(\n modulePath: string,\n options?: ForkOptions\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess\nexport function fork(\n modulePath: string,\n args?: ForkOptions | ReadonlyArray<string>,\n options?: WithExternalID<ForkOptions>\n): ChildProcess {\n if (isNotArray<ForkOptions>(args)) {\n options = args\n args = []\n }\n return cpFork(modulePath, args, spawnOpts(options || {}, getExclude(k)))\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";AAQA,MAAM,WAAW,mBAAmB;IAElC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAG1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAGjC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AA0BD,eAAO,MAAM,KAAK;0BAKgB,mBAAmB;CAFpD,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,mBA6CjC,CAAA"}
|
|
@@ -4,15 +4,16 @@ exports.getProcessInfo = exports.reset = void 0;
|
|
|
4
4
|
// we always want this
|
|
5
5
|
const p = process;
|
|
6
6
|
p.setSourceMapsEnabled(true);
|
|
7
|
+
const node_url_1 = require("node:url");
|
|
7
8
|
const uuid_1 = require("uuid");
|
|
8
9
|
const envKey = (k) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`;
|
|
9
10
|
const getEnv = (k) => process.env[envKey(k)];
|
|
10
11
|
const setEnv = (k, v) => (process.env[envKey(k)] = v);
|
|
11
12
|
const delEnv = (k) => delete process.env[envKey(k)];
|
|
13
|
+
const register_cjs_js_1 = require("./register-cjs.js");
|
|
12
14
|
const register_coverage_js_1 = require("./register-coverage.js");
|
|
13
15
|
const register_env_js_1 = require("./register-env.js");
|
|
14
16
|
const register_process_end_js_1 = require("./register-process-end.js");
|
|
15
|
-
const register_cjs_js_1 = require("./register-cjs.js");
|
|
16
17
|
// this module is hybridized. In node v20, it's the *commonjs* one that
|
|
17
18
|
// gets loaded, because the esm loader context can't modify the main thread
|
|
18
19
|
// except via communication over the port to the globalPreload env.
|
|
@@ -31,6 +32,11 @@ exports.reset = reset;
|
|
|
31
32
|
const getProcessInfo = () => {
|
|
32
33
|
if (g[kProcessInfo])
|
|
33
34
|
return g[kProcessInfo];
|
|
35
|
+
const argv1 = process.argv[1];
|
|
36
|
+
// we only test this in CJS, but file:// only prepended in ESM
|
|
37
|
+
/* c8 ignore start */
|
|
38
|
+
const main = argv1.startsWith('file://') ? (0, node_url_1.fileURLToPath)(argv1) : argv1;
|
|
39
|
+
/* c8 ignore stop */
|
|
34
40
|
g[kProcessInfo] = {
|
|
35
41
|
hrstart: process.hrtime(),
|
|
36
42
|
date: new Date().toISOString(),
|
|
@@ -42,7 +48,7 @@ const getProcessInfo = () => {
|
|
|
42
48
|
ppid: process.ppid,
|
|
43
49
|
parent: getEnv('parent') || null,
|
|
44
50
|
uuid: (0, uuid_1.v4)(),
|
|
45
|
-
files: [],
|
|
51
|
+
files: [main],
|
|
46
52
|
sources: Object.create(null),
|
|
47
53
|
};
|
|
48
54
|
if (!g[kProcessInfo].parent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";;;AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,+BAAiC;
|
|
1
|
+
{"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";;;AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,uCAAwC;AACxC,+BAAiC;AA2BjC,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,sBAAsB,CAAC,CAAC,WAAW,EAAE,GAAG,CAAA;AACtE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;AACpD,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACrE,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,OAAO,OA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I,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,IAAI;QAChC,IAAI,EAAE,IAAA,SAAI,GAAE;QACZ,KAAK,EAAE,CAAC,IAAI,CAAC;QACb,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;KAC7B,CAAA;IAED,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE;QAC3B,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAA;QAC3C,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;KACrC;SAAM;QACL,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAA;KACtC;IACD,oDAAoD;IACpD,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAA;IACtC,MAAM,UAAU,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,UAAU,EAAE;QACd,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,IAAA,0BAAW,GAAE,CAAA;IACb,IAAA,0BAAW,GAAE,CAAA;IACb,IAAA,+BAAgB,GAAE,CAAA;IAClB,IAAA,kCAAkB,GAAE,CAAA;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA;AA7CY,QAAA,cAAc,kBA6C1B","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n}\np.setSourceMapsEnabled(true)\n\nimport { fileURLToPath } from 'node:url'\nimport { v4 as uuid } from 'uuid'\nexport interface ProcessInfoNodeData {\n // set initially, but deleted before it is written\n hrstart?: [number, number]\n\n // always set\n date: string\n argv: string[]\n execArgv: string[]\n NODE_OPTIONS?: string\n cwd: string\n pid: number\n ppid: number\n parent: string | null\n uuid: string\n files: string[]\n sources: Record<string, string[]>\n\n // fields that are only set when the process completes\n root?: string | null\n externalID?: string | null\n code?: number | null\n signal?: NodeJS.Signals | null\n runtime?: number\n globalsAdded?: string[]\n}\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => process.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (process.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete process.env[envKey(k)]\n\nimport { register as registerCJS } from './register-cjs.js'\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\n\n// this module is hybridized. In node v20, it's the *commonjs* one that\n// gets loaded, because the esm loader context can't modify the main thread\n// except via communication over the port to the globalPreload env.\n// So, we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n const argv1 = process.argv[1]\n // we only test this in CJS, but file:// only prepended in ESM\n /* c8 ignore start */\n const main = argv1.startsWith('file://') ? fileURLToPath(argv1) : argv1\n /* c8 ignore stop */\n\n g[kProcessInfo] = {\n hrstart: process.hrtime(),\n date: new Date().toISOString(),\n argv: process.argv,\n execArgv: process.execArgv,\n NODE_OPTIONS: process.env.NODE_OPTIONS,\n cwd: process.cwd(),\n pid: process.pid,\n ppid: process.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [main],\n sources: Object.create(null),\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n registerCJS()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n\n return g[kProcessInfo]\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-lengths.d.ts","sourceRoot":"","sources":["../../lib/line-lengths.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,eAAe,aAAc,MAAM,WAAW,MAAM,SAWhE,CAAA;AAED,eAAO,MAAM,cAAc,aAAc,MAAM,yBAG9C,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO: Refactor once https://github.com/nodejs/node/issues/48460 fixed
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getLineLengths = exports.saveLineLengths = void 0;
|
|
5
|
+
const url_1 = require("url");
|
|
6
|
+
const kLLC = Symbol.for('@tapjs/processinfo lineLength cache');
|
|
7
|
+
const g = global;
|
|
8
|
+
const cache = g[kLLC] || new Map();
|
|
9
|
+
g[kLLC] = cache;
|
|
10
|
+
const sourceMapComment = '//# sourceMappingURL=';
|
|
11
|
+
const saveLineLengths = (filename, content) => {
|
|
12
|
+
if (filename.startsWith('file://'))
|
|
13
|
+
filename = (0, url_1.fileURLToPath)(filename);
|
|
14
|
+
if (cache.has(filename))
|
|
15
|
+
return;
|
|
16
|
+
// no need if it's not sourcemapped
|
|
17
|
+
const ll = !content.includes(sourceMapComment)
|
|
18
|
+
? []
|
|
19
|
+
: content
|
|
20
|
+
.replace(/[\n\u2028\u2029]$/, '')
|
|
21
|
+
.split(/\n|\u2028|\u2029/)
|
|
22
|
+
.map(l => l.length);
|
|
23
|
+
cache.set(filename, ll);
|
|
24
|
+
};
|
|
25
|
+
exports.saveLineLengths = saveLineLengths;
|
|
26
|
+
const getLineLengths = (filename) => {
|
|
27
|
+
if (filename.startsWith('file://'))
|
|
28
|
+
filename = (0, url_1.fileURLToPath)(filename);
|
|
29
|
+
return cache.get(filename);
|
|
30
|
+
};
|
|
31
|
+
exports.getLineLengths = getLineLengths;
|
|
32
|
+
//# sourceMappingURL=line-lengths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-lengths.js","sourceRoot":"","sources":["../../lib/line-lengths.ts"],"names":[],"mappings":";AAAA,wEAAwE;;;AAExE,6BAAmC;AAEnC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAA;AAC9D,MAAM,CAAC,GAAG,MAET,CAAA;AACD,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAoB,CAAA;AACpD,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;AAEf,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AACzC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAE,EAAE;IACnE,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,QAAQ,GAAG,IAAA,mBAAa,EAAC,QAAQ,CAAC,CAAA;IACtE,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAM;IAC/B,mCAAmC;IACnC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC5C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,OAAO;aACJ,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;aAChC,KAAK,CAAC,kBAAkB,CAAC;aACzB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACzB,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACzB,CAAC,CAAA;AAXY,QAAA,eAAe,mBAW3B;AAEM,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE;IACjD,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,QAAQ,GAAG,IAAA,mBAAa,EAAC,QAAQ,CAAC,CAAA;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC5B,CAAC,CAAA;AAHY,QAAA,cAAc,kBAG1B","sourcesContent":["// TODO: Refactor once https://github.com/nodejs/node/issues/48460 fixed\n\nimport { fileURLToPath } from 'url'\n\nconst kLLC = Symbol.for('@tapjs/processinfo lineLength cache')\nconst g = global as {\n [kLLC]?: Map<string, number[]>\n}\nconst cache = g[kLLC] || new Map<string, number[]>()\ng[kLLC] = cache\n\nconst sourceMapComment = '//# sourceMappingURL='\nexport const saveLineLengths = (filename: string, content: string) => {\n if (filename.startsWith('file://')) filename = fileURLToPath(filename)\n if (cache.has(filename)) return\n // no need if it's not sourcemapped\n const ll = !content.includes(sourceMapComment)\n ? []\n : content\n .replace(/[\\n\\u2028\\u2029]$/, '')\n .split(/\\n|\\u2028|\\u2029/)\n .map(l => l.length)\n cache.set(filename, ll)\n}\n\nexport const getLineLengths = (filename: string) => {\n if (filename.startsWith('file://')) filename = fileURLToPath(filename)\n return cache.get(filename)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-cjs.d.ts","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register-cjs.d.ts","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,YAgBpB,CAAA"}
|
package/dist/cjs/register-cjs.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.register = void 0;
|
|
|
5
5
|
const pirates_1 = require("pirates");
|
|
6
6
|
const get_exclude_js_1 = require("./get-exclude.js");
|
|
7
7
|
const get_process_info_js_1 = require("./get-process-info.js");
|
|
8
|
+
const line_lengths_js_1 = require("./line-lengths.js");
|
|
8
9
|
const kRegisterCJS = Symbol.for('@tapjs/processinfo.registerCJS');
|
|
9
10
|
const g = global;
|
|
10
11
|
const register = () => {
|
|
@@ -15,8 +16,12 @@ const register = () => {
|
|
|
15
16
|
const exclude = (0, get_exclude_js_1.getExclude)('_TAPJS_PROCESSINFO_EXCLUDE_', false);
|
|
16
17
|
(0, pirates_1.addHook)((code, filename) => {
|
|
17
18
|
(0, get_process_info_js_1.getProcessInfo)().files.push(filename);
|
|
19
|
+
(0, line_lengths_js_1.saveLineLengths)(filename, code);
|
|
18
20
|
return code;
|
|
19
|
-
}, {
|
|
21
|
+
}, {
|
|
22
|
+
exts: ['.js', '.cjs', '.ts', '.cts', '.jsx', '.tsx'],
|
|
23
|
+
matcher: filename => !exclude.test(filename),
|
|
24
|
+
});
|
|
20
25
|
};
|
|
21
26
|
exports.register = register;
|
|
22
27
|
//# sourceMappingURL=register-cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-cjs.js","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,qCAAiC;AACjC,qDAA6C;AAC7C,+DAAsD;
|
|
1
|
+
{"version":3,"file":"register-cjs.js","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,qCAAiC;AACjC,qDAA6C;AAC7C,+DAAsD;AACtD,uDAAmD;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;AACjE,MAAM,CAAC,GAAG,MAET,CAAA;AAEM,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,IAAI,CAAC,CAAC,YAAY,CAAC;QAAE,OAAM;IAC3B,CAAC,CAAC,YAAY,CAAC,GAAG,IAAI,CAAA;IACtB,wDAAwD;IACxD,MAAM,OAAO,GAAG,IAAA,2BAAU,EAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;IAChE,IAAA,iBAAO,EACL,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;QACjB,IAAA,oCAAc,GAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACrC,IAAA,iCAAe,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC,EACD;QACE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACpD,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC7C,CACF,CAAA;AACH,CAAC,CAAA;AAhBY,QAAA,QAAQ,YAgBpB","sourcesContent":["// commonjs style loader hook, modifying require.extensions\nimport { addHook } from 'pirates'\nimport { getExclude } from './get-exclude.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport { saveLineLengths } from './line-lengths.js'\n\nconst kRegisterCJS = Symbol.for('@tapjs/processinfo.registerCJS')\nconst g = global as typeof globalThis & {\n [kRegisterCJS]?: boolean\n}\n\nexport const register = () => {\n if (g[kRegisterCJS]) return\n g[kRegisterCJS] = true\n // by default we include everything in processInfo.files\n const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false)\n addHook(\n (code, filename) => {\n getProcessInfo().files.push(filename)\n saveLineLengths(filename, code)\n return code\n },\n {\n exts: ['.js', '.cjs', '.ts', '.cts', '.jsx', '.tsx'],\n matcher: filename => !exclude.test(filename),\n }\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAG3D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAiDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SAyDjC,CAAA"}
|
|
@@ -9,6 +9,7 @@ const inspector_1 = require("inspector");
|
|
|
9
9
|
const module_1 = require("module");
|
|
10
10
|
const url_1 = require("url");
|
|
11
11
|
const get_exclude_js_1 = require("./get-exclude.js");
|
|
12
|
+
const line_lengths_js_1 = require("./line-lengths.js");
|
|
12
13
|
exports.SESSION = undefined;
|
|
13
14
|
// NB: coverage exclusion is in addition to processinfo
|
|
14
15
|
// exclusion. Only show coverage for a file we care
|
|
@@ -19,7 +20,10 @@ const exclude = (0, get_exclude_js_1.getExclude)('_TAPJS_PROCESSINFO_COV_EXCLUDE
|
|
|
19
20
|
// that pass the exclusion RegExp filter. If included in this list,
|
|
20
21
|
// then coverage will be recorded, even if it matches exclude.
|
|
21
22
|
const cfEnv = process.env._TAPJS_PROCESSINFO_COV_FILES_ || '';
|
|
22
|
-
const coveredFiles = cfEnv
|
|
23
|
+
const coveredFiles = cfEnv
|
|
24
|
+
.trim()
|
|
25
|
+
.split('\n')
|
|
26
|
+
.filter(f => !!f);
|
|
23
27
|
const fileCovered = (f, s, files = []) => {
|
|
24
28
|
const testFiles = [f];
|
|
25
29
|
if (s) {
|
|
@@ -63,16 +67,6 @@ const register = () => {
|
|
|
63
67
|
};
|
|
64
68
|
exports.register = register;
|
|
65
69
|
/* c8 ignore stop */
|
|
66
|
-
// NB: this is the *generated* line lengths, not the source
|
|
67
|
-
const lineLengths = (f) => {
|
|
68
|
-
try {
|
|
69
|
-
const content = (0, fs_1.readFileSync)(f, 'utf8');
|
|
70
|
-
return content.split(/\n|\u2028|\u2029/).map(l => l.length);
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return [];
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
70
|
const coverageOnProcessEnd = (cwd, processInfo) => {
|
|
77
71
|
// Similar to the coverage tracking bootstrap problem above, c8
|
|
78
72
|
// doesn't see that this function runs, even though it DOES see
|
|
@@ -110,7 +104,7 @@ const coverageOnProcessEnd = (cwd, processInfo) => {
|
|
|
110
104
|
if (s) {
|
|
111
105
|
const { payload } = s;
|
|
112
106
|
sourceMapCache[obj.url] = Object.assign(Object.create(null), {
|
|
113
|
-
lineLengths:
|
|
107
|
+
lineLengths: (0, line_lengths_js_1.getLineLengths)(f),
|
|
114
108
|
data: payload,
|
|
115
109
|
});
|
|
116
110
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAChE,2BAA2D;AAC3D,yCAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAChE,2BAA2D;AAC3D,yCAAmC;AACnC,mCAAmE;AACnE,6BAAmC;AACnC,qDAA6C;AAE7C,uDAAgD;AAErC,QAAA,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;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AAkB,EAAE,cAAc;SACnC,CAAC,CAAA;QAEF,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;YACnC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;gBAC3B,OAAO,KAAK,CAAA;aACb;YACD,MAAM,CAAC,GAAG,IAAA,mBAAa,EAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YAChC,6BAA6B;YAC7B,MAAM,CAAC,GAAG,IAAA,sBAAa,EAAC,CAAC,CAAC,CAAA;YAC1B,IAAI,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE;gBAClD,OAAO,KAAK,CAAA;aACb;YACD,IAAI,CAAC,EAAE;gBACL,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;gBACrB,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,IAAA,gCAAc,EAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,IAAA,kBAAa,EAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AA3DY,QAAA,oBAAoB,wBA2DhC;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst enabled = process.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, readFileSync, writeFileSync } from 'fs'\nimport { Session } from 'inspector'\nimport { findSourceMap, SourceMap, SourceMapPayload } from 'module'\nimport { fileURLToPath } from 'url'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './get-process-info.js'\nimport {getLineLengths} from './line-lengths.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = process.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(fileURLToPath(src))\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n process.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n const s = findSourceMap(f)\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n if (s) {\n const { payload } = s\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-env.d.ts","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register-env.d.ts","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,QAAQ,YAQpB,CAAA"}
|
package/dist/cjs/register-env.js
CHANGED
|
@@ -11,14 +11,16 @@ const { hasOwnProperty } = Object.prototype;
|
|
|
11
11
|
const getEnvs = (env) => {
|
|
12
12
|
// load it here so that it isn't cached before the loader attaches
|
|
13
13
|
// in self-test scenario.
|
|
14
|
-
|
|
15
|
-
return Object.fromEntries(Object.entries(
|
|
16
|
-
.filter(([k]) => !hasOwnProperty.call(env
|
|
17
|
-
.concat([
|
|
14
|
+
// copy all of OUR envs, if not specifically set on the env object
|
|
15
|
+
return Object.fromEntries(Object.entries(process.env)
|
|
16
|
+
.filter(([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k))
|
|
17
|
+
.concat([
|
|
18
|
+
['NODE_OPTIONS', (0, node_options_env_js_1.nodeOptionsEnv)(process.env, process.execArgv)],
|
|
19
|
+
]));
|
|
18
20
|
};
|
|
19
21
|
const register = () => {
|
|
20
22
|
process_on_spawn_1.default.addListener(obj => {
|
|
21
|
-
obj.env = Object.assign(obj.env || {}, getEnvs(obj.env));
|
|
23
|
+
obj.env = Object.assign(obj.env || { ...process.env }, getEnvs(obj.env));
|
|
22
24
|
return obj;
|
|
23
25
|
});
|
|
24
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-env.js","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":";;;;;;AAAA,wEAA6C;AAC7C,+DAAsD;AAEtD,MAAM,KAAK,GAAG,sBAAsB,CAAA;AACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,CAAA;AAE3C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE;IAC1C,kEAAkE;IAClE,yBAAyB;IACzB,
|
|
1
|
+
{"version":3,"file":"register-env.js","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":";;;;;;AAAA,wEAA6C;AAC7C,+DAAsD;AAEtD,MAAM,KAAK,GAAG,sBAAsB,CAAA;AACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,CAAA;AAE3C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE;IAC1C,kEAAkE;IAClE,yBAAyB;IACzB,kEAAkE;IAClE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;SACxB,MAAM,CACL,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAChE;SACA,MAAM,CAAC;QACN,CAAC,cAAc,EAAE,IAAA,oCAAc,EAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAChE,CAAC,CACL,CAAA;AACH,CAAC,CAAA;AAEM,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,0BAAc,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QAC/B,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CACrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CACjB,CAAA;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,QAAQ,YAQpB","sourcesContent":["import processOnSpawn from 'process-on-spawn'\nimport { nodeOptionsEnv } from './node-options-env.js'\n\nconst envRE = /^_TAPJS_PROCESSINFO_/\nconst { hasOwnProperty } = Object.prototype\n\nconst getEnvs = (env?: NodeJS.ProcessEnv) => {\n // load it here so that it isn't cached before the loader attaches\n // in self-test scenario.\n // copy all of OUR envs, if not specifically set on the env object\n return Object.fromEntries(\n Object.entries(process.env)\n .filter(\n ([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k)\n )\n .concat([\n ['NODE_OPTIONS', nodeOptionsEnv(process.env, process.execArgv)],\n ])\n )\n}\n\nexport const register = () => {\n processOnSpawn.addListener(obj => {\n obj.env = Object.assign(\n obj.env || { ...process.env },\n getEnvs(obj.env)\n )\n return obj\n })\n}\n"]}
|
package/dist/mjs/esm.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esm.d.mts","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"esm.d.mts","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAQlD,cAAc,YAAY,CAAA;AAU1B,KAAK,MAAM,GAAG;IACZ,WAAW,EAAE,CAAC,CAAC,EAAE,YAAY,KAAK,GAAG,CAAA;CACtC,CAAA;AAED,eAAO,MAAM,aAAa,YAAa;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,WAwBvD,CAAA;AAeD,eAAO,MAAM,IAAI,QACV,MAAM,WACF,GAAG,YACF,QAAQ,iBAqBnB,CAAA"}
|
package/dist/mjs/esm.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { parse } from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { getExclude } from './get-exclude.js';
|
|
5
5
|
import { getProcessInfo } from './get-process-info.js';
|
|
6
|
+
import { saveLineLengths } from './line-lengths.js';
|
|
6
7
|
import { resolve } from './require-resolve.js';
|
|
7
8
|
// copy main module so that we can --loader=@tapjs/processinfo and use
|
|
8
9
|
// this as the entry point as well.
|
|
@@ -20,42 +21,52 @@ if (typeof port !== 'undefined') {
|
|
|
20
21
|
const { fileURLToPath } = getBuiltin('url')
|
|
21
22
|
const require = createRequire(${JSON.stringify(base)})
|
|
22
23
|
const { getProcessInfo } = require('./get-process-info.js')
|
|
24
|
+
const { saveLineLengths } = require('./line-lengths.js')
|
|
23
25
|
// must be called eagerly here.
|
|
24
26
|
// this does all the registration as well.
|
|
25
27
|
const processInfo = getProcessInfo()
|
|
26
28
|
port.onmessage = (e) => {
|
|
27
|
-
const filename = e.data
|
|
29
|
+
const { filename, content } = e.data
|
|
28
30
|
processInfo.files.push(filename)
|
|
31
|
+
saveLineLengths(filename, content)
|
|
29
32
|
}
|
|
30
33
|
port.unref()
|
|
31
34
|
}
|
|
32
35
|
`;
|
|
33
36
|
};
|
|
34
37
|
const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false);
|
|
38
|
+
const record = (url, content) => {
|
|
39
|
+
const filename = url.startsWith('file://') ? fileURLToPath(url) : url;
|
|
40
|
+
if (exclude.test(filename))
|
|
41
|
+
return;
|
|
42
|
+
if (PORT) {
|
|
43
|
+
PORT.postMessage({ filename, content });
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
// call lazily so we don't double-register
|
|
47
|
+
getProcessInfo().files.push(filename);
|
|
48
|
+
if (content)
|
|
49
|
+
saveLineLengths(filename, content);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
35
52
|
export const load = async (url, context, nextLoad) => {
|
|
36
|
-
if (
|
|
53
|
+
if (url.startsWith('file://')) {
|
|
37
54
|
const filename = fileURLToPath(url);
|
|
38
|
-
if (!exclude.test(filename)) {
|
|
39
|
-
if (PORT) {
|
|
40
|
-
PORT.postMessage(filename);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
// call lazily so we don't double-register
|
|
44
|
-
getProcessInfo().files.push(filename);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
55
|
const { ext } = parse(filename);
|
|
48
56
|
// Package bins will sometimes have an extensionless bin script
|
|
49
57
|
// instead of just naming their extensioned file and letting npm
|
|
50
58
|
// symlink it for them. Don't blow up when this happens, just tell
|
|
51
59
|
// node that it's commonjs.
|
|
52
60
|
if (!ext) {
|
|
61
|
+
record(url);
|
|
53
62
|
return {
|
|
54
63
|
format: 'commonjs',
|
|
55
64
|
shortCircuit: true,
|
|
56
65
|
};
|
|
57
66
|
}
|
|
58
67
|
}
|
|
59
|
-
|
|
68
|
+
const ret = await nextLoad(url, context);
|
|
69
|
+
record(url, String(ret.source));
|
|
70
|
+
return ret;
|
|
60
71
|
};
|
|
61
72
|
//# sourceMappingURL=esm.mjs.map
|
package/dist/mjs/esm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAE9C,sEAAsE;AACtE,mCAAmC;AACnC,cAAc,YAAY,CAAA;AAa1B,IAAI,IAAI,GAAuB,SAAS,CAAA;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAA0B,EAAE,EAAE;IAC1D,2DAA2D;IAC3D,sCAAsC;IACtC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IACrC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IAC9B,IAAI,GAAG,IAAI,CAAA;IACX,OAAO;;;;kCAIyB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"esm.mjs","sourceRoot":"","sources":["../../lib/esm.mts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,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,GAAG,CAAC,CAAA;QACnC,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC/B,+DAA+D;QAC/D,gEAAgE;QAChE,kEAAkE;QAClE,2BAA2B;QAC3B,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,CAAC,GAAG,CAAC,CAAA;YACX,OAAO;gBACL,MAAM,EAAE,UAAU;gBAClB,YAAY,EAAE,IAAI;aACnB,CAAA;SACF;KACF;IAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACxC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;IAC/B,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["// usage: node '--loader=@tapjs/processinfo/esm' foo.mjs\nimport { parse } from 'path'\nimport { fileURLToPath } from 'url'\nimport type { Serializable } from 'worker_threads'\nimport { getExclude } from './get-exclude.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport { saveLineLengths } from './line-lengths.js'\nimport { resolve } from './require-resolve.js'\n\n// copy main module so that we can --loader=@tapjs/processinfo and use\n// this as the entry point as well.\nexport * from './index.js'\n\n// on Node v20, loaders are executed in a separate isolated environment\n// As a result, to register coverage and track files, we need to act in\n// the globalPreload function. The load() method posts a message with the\n// filename being loaded, because any registrations that happen in the\n// loader thread will not have any effect.\n// The check for the 'port' being undefined is to allow for support back to\n// 16.12, which had a globalPreload method, but did not have a sendMessage\n// port in that environment.\ntype GPPort = {\n postMessage: (x: Serializable) => any\n}\nlet PORT: undefined | GPPort = undefined\nexport const globalPreload = (context: { port?: GPPort }) => {\n // this will be something like path/to/dist/mjs/lib/esm.mjs\n // but we need path/to/dist/cjs/cjs.js\n const base = resolve('../cjs/cjs.js')\n const { port } = context || {}\n PORT = port\n return `\nif (typeof port !== 'undefined') {\n const { createRequire, findSourceMap } = getBuiltin('module')\n const { fileURLToPath } = getBuiltin('url')\n const require = createRequire(${JSON.stringify(base)})\n const { getProcessInfo } = require('./get-process-info.js')\n const { saveLineLengths } = require('./line-lengths.js')\n // must be called eagerly here.\n // this does all the registration as well.\n const processInfo = getProcessInfo()\n port.onmessage = (e) => {\n const { filename, content } = e.data\n processInfo.files.push(filename)\n saveLineLengths(filename, content)\n }\n port.unref()\n}\n`\n}\n\nconst exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false)\nconst record = (url: string, content?: string) => {\n const filename = url.startsWith('file://') ? fileURLToPath(url) : url\n if (exclude.test(filename)) return\n if (PORT) {\n PORT.postMessage({ filename, content })\n } else {\n // call lazily so we don't double-register\n getProcessInfo().files.push(filename)\n if (content) saveLineLengths(filename, content)\n }\n}\n\nexport const load = async (\n url: string,\n context: any,\n nextLoad: Function\n) => {\n if (url.startsWith('file://')) {\n const filename = fileURLToPath(url)\n const { ext } = parse(filename)\n // Package bins will sometimes have an extensionless bin script\n // instead of just naming their extensioned file and letting npm\n // symlink it for them. Don't blow up when this happens, just tell\n // node that it's commonjs.\n if (!ext) {\n record(url)\n return {\n format: 'commonjs',\n shortCircuit: true,\n }\n }\n }\n\n const ret = await nextLoad(url, context)\n record(url, String(ret.source))\n return ret\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"get-process-info.d.ts","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":";AAQA,MAAM,WAAW,mBAAmB;IAElC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAG1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAGjC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;CACxB;AA0BD,eAAO,MAAM,KAAK;0BAKgB,mBAAmB;CAFpD,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,mBA6CjC,CAAA"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// we always want this
|
|
2
2
|
const p = process;
|
|
3
3
|
p.setSourceMapsEnabled(true);
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import { v4 as uuid } from 'uuid';
|
|
5
6
|
const envKey = (k) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`;
|
|
6
7
|
const getEnv = (k) => process.env[envKey(k)];
|
|
7
8
|
const setEnv = (k, v) => (process.env[envKey(k)] = v);
|
|
8
9
|
const delEnv = (k) => delete process.env[envKey(k)];
|
|
10
|
+
import { register as registerCJS } from './register-cjs.js';
|
|
9
11
|
import { register as registerCoverage } from './register-coverage.js';
|
|
10
12
|
import { register as registerEnv } from './register-env.js';
|
|
11
13
|
import { register as registerProcessEnd } from './register-process-end.js';
|
|
12
|
-
import { register as registerCJS } from './register-cjs.js';
|
|
13
14
|
// this module is hybridized. In node v20, it's the *commonjs* one that
|
|
14
15
|
// gets loaded, because the esm loader context can't modify the main thread
|
|
15
16
|
// except via communication over the port to the globalPreload env.
|
|
@@ -27,6 +28,11 @@ export const reset = () => {
|
|
|
27
28
|
export const getProcessInfo = () => {
|
|
28
29
|
if (g[kProcessInfo])
|
|
29
30
|
return g[kProcessInfo];
|
|
31
|
+
const argv1 = process.argv[1];
|
|
32
|
+
// we only test this in CJS, but file:// only prepended in ESM
|
|
33
|
+
/* c8 ignore start */
|
|
34
|
+
const main = argv1.startsWith('file://') ? fileURLToPath(argv1) : argv1;
|
|
35
|
+
/* c8 ignore stop */
|
|
30
36
|
g[kProcessInfo] = {
|
|
31
37
|
hrstart: process.hrtime(),
|
|
32
38
|
date: new Date().toISOString(),
|
|
@@ -38,7 +44,7 @@ export const getProcessInfo = () => {
|
|
|
38
44
|
ppid: process.ppid,
|
|
39
45
|
parent: getEnv('parent') || null,
|
|
40
46
|
uuid: uuid(),
|
|
41
|
-
files: [],
|
|
47
|
+
files: [main],
|
|
42
48
|
sources: Object.create(null),
|
|
43
49
|
};
|
|
44
50
|
if (!g[kProcessInfo].parent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"get-process-info.js","sourceRoot":"","sources":["../../lib/get-process-info.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,GAAG,OAET,CAAA;AACD,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAA;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAA;AA2BjC,MAAM,MAAM,GAAG,CAAC,CA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AM,CAAC,aAAa,CAAC,CAAA;IACxC,IAAI,UAAU,EAAE;QACd,CAAC,CAAC,YAAY,CAAC,CAAC,UAAU,GAAG,UAAU,CAAA;QACvC,gEAAgE;QAChE,MAAM,CAAC,aAAa,CAAC,CAAA;KACtB;IAED,WAAW,EAAE,CAAA;IACb,WAAW,EAAE,CAAA;IACb,gBAAgB,EAAE,CAAA;IAClB,kBAAkB,EAAE,CAAA;IAEpB,OAAO,CAAC,CAAC,YAAY,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["// we always want this\nconst p = process as NodeJS.Process & {\n setSourceMapsEnabled(v: boolean): void\n}\np.setSourceMapsEnabled(true)\n\nimport { fileURLToPath } from 'node:url'\nimport { v4 as uuid } from 'uuid'\nexport interface ProcessInfoNodeData {\n // set initially, but deleted before it is written\n hrstart?: [number, number]\n\n // always set\n date: string\n argv: string[]\n execArgv: string[]\n NODE_OPTIONS?: string\n cwd: string\n pid: number\n ppid: number\n parent: string | null\n uuid: string\n files: string[]\n sources: Record<string, string[]>\n\n // fields that are only set when the process completes\n root?: string | null\n externalID?: string | null\n code?: number | null\n signal?: NodeJS.Signals | null\n runtime?: number\n globalsAdded?: string[]\n}\n\nconst envKey = (k: string) => `_TAPJS_PROCESSINFO_${k.toUpperCase()}_`\nconst getEnv = (k: string) => process.env[envKey(k)]\nconst setEnv = (k: string, v: string) => (process.env[envKey(k)] = v)\nconst delEnv = (k: string) => delete process.env[envKey(k)]\n\nimport { register as registerCJS } from './register-cjs.js'\nimport { register as registerCoverage } from './register-coverage.js'\nimport { register as registerEnv } from './register-env.js'\nimport { register as registerProcessEnd } from './register-process-end.js'\n\n// this module is hybridized. In node v20, it's the *commonjs* one that\n// gets loaded, because the esm loader context can't modify the main thread\n// except via communication over the port to the globalPreload env.\n// So, we have to store our singleton on the global.\n//\n// If it later loads the esm form of this module, that's fine, because it'll\n// see the global processInfo object, and not re-register anything.\n\nconst kProcessInfo = Symbol.for('@tapjs/processinfo.ProcessInfoNodeData')\nconst g = global as typeof globalThis & {\n [kProcessInfo]?: ProcessInfoNodeData\n}\n\n// only used for tests so we can simulate multiple processes\nexport const reset = () => {\n g[kProcessInfo] = undefined\n return { getProcessInfo }\n}\n\nexport const getProcessInfo = (): ProcessInfoNodeData => {\n if (g[kProcessInfo]) return g[kProcessInfo]\n\n const argv1 = process.argv[1]\n // we only test this in CJS, but file:// only prepended in ESM\n /* c8 ignore start */\n const main = argv1.startsWith('file://') ? fileURLToPath(argv1) : argv1\n /* c8 ignore stop */\n\n g[kProcessInfo] = {\n hrstart: process.hrtime(),\n date: new Date().toISOString(),\n argv: process.argv,\n execArgv: process.execArgv,\n NODE_OPTIONS: process.env.NODE_OPTIONS,\n cwd: process.cwd(),\n pid: process.pid,\n ppid: process.ppid,\n parent: getEnv('parent') || null,\n uuid: uuid(),\n files: [main],\n sources: Object.create(null),\n }\n\n if (!g[kProcessInfo].parent) {\n g[kProcessInfo].root = g[kProcessInfo].uuid\n setEnv('root', g[kProcessInfo].uuid)\n } else {\n g[kProcessInfo].root = getEnv('root')\n }\n // this is the parent of any further child processes\n setEnv('parent', g[kProcessInfo].uuid)\n const externalID = getEnv('external_id')\n if (externalID) {\n g[kProcessInfo].externalID = externalID\n // externalID only applies to ONE process, not all its children.\n delEnv('external_id')\n }\n\n registerCJS()\n registerEnv()\n registerCoverage()\n registerProcessEnd()\n\n return g[kProcessInfo]\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-lengths.d.ts","sourceRoot":"","sources":["../../lib/line-lengths.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,eAAe,aAAc,MAAM,WAAW,MAAM,SAWhE,CAAA;AAED,eAAO,MAAM,cAAc,aAAc,MAAM,yBAG9C,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// TODO: Refactor once https://github.com/nodejs/node/issues/48460 fixed
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
const kLLC = Symbol.for('@tapjs/processinfo lineLength cache');
|
|
4
|
+
const g = global;
|
|
5
|
+
const cache = g[kLLC] || new Map();
|
|
6
|
+
g[kLLC] = cache;
|
|
7
|
+
const sourceMapComment = '//# sourceMappingURL=';
|
|
8
|
+
export const saveLineLengths = (filename, content) => {
|
|
9
|
+
if (filename.startsWith('file://'))
|
|
10
|
+
filename = fileURLToPath(filename);
|
|
11
|
+
if (cache.has(filename))
|
|
12
|
+
return;
|
|
13
|
+
// no need if it's not sourcemapped
|
|
14
|
+
const ll = !content.includes(sourceMapComment)
|
|
15
|
+
? []
|
|
16
|
+
: content
|
|
17
|
+
.replace(/[\n\u2028\u2029]$/, '')
|
|
18
|
+
.split(/\n|\u2028|\u2029/)
|
|
19
|
+
.map(l => l.length);
|
|
20
|
+
cache.set(filename, ll);
|
|
21
|
+
};
|
|
22
|
+
export const getLineLengths = (filename) => {
|
|
23
|
+
if (filename.startsWith('file://'))
|
|
24
|
+
filename = fileURLToPath(filename);
|
|
25
|
+
return cache.get(filename);
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=line-lengths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"line-lengths.js","sourceRoot":"","sources":["../../lib/line-lengths.ts"],"names":[],"mappings":"AAAA,wEAAwE;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AAEnC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAA;AAC9D,MAAM,CAAC,GAAG,MAET,CAAA;AACD,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAoB,CAAA;AACpD,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;AAEf,MAAM,gBAAgB,GAAG,uBAAuB,CAAA;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAE,OAAe,EAAE,EAAE;IACnE,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IACtE,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAM;IAC/B,mCAAmC;IACnC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC5C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,OAAO;aACJ,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;aAChC,KAAK,CAAC,kBAAkB,CAAC;aACzB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACzB,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AACzB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAgB,EAAE,EAAE;IACjD,IAAI,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC;QAAE,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAA;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC5B,CAAC,CAAA","sourcesContent":["// TODO: Refactor once https://github.com/nodejs/node/issues/48460 fixed\n\nimport { fileURLToPath } from 'url'\n\nconst kLLC = Symbol.for('@tapjs/processinfo lineLength cache')\nconst g = global as {\n [kLLC]?: Map<string, number[]>\n}\nconst cache = g[kLLC] || new Map<string, number[]>()\ng[kLLC] = cache\n\nconst sourceMapComment = '//# sourceMappingURL='\nexport const saveLineLengths = (filename: string, content: string) => {\n if (filename.startsWith('file://')) filename = fileURLToPath(filename)\n if (cache.has(filename)) return\n // no need if it's not sourcemapped\n const ll = !content.includes(sourceMapComment)\n ? []\n : content\n .replace(/[\\n\\u2028\\u2029]$/, '')\n .split(/\\n|\\u2028|\\u2029/)\n .map(l => l.length)\n cache.set(filename, ll)\n}\n\nexport const getLineLengths = (filename: string) => {\n if (filename.startsWith('file://')) filename = fileURLToPath(filename)\n return cache.get(filename)\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-cjs.d.ts","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register-cjs.d.ts","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,QAAQ,YAgBpB,CAAA"}
|
package/dist/mjs/register-cjs.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { addHook } from 'pirates';
|
|
3
3
|
import { getExclude } from './get-exclude.js';
|
|
4
4
|
import { getProcessInfo } from './get-process-info.js';
|
|
5
|
+
import { saveLineLengths } from './line-lengths.js';
|
|
5
6
|
const kRegisterCJS = Symbol.for('@tapjs/processinfo.registerCJS');
|
|
6
7
|
const g = global;
|
|
7
8
|
export const register = () => {
|
|
@@ -12,7 +13,11 @@ export const register = () => {
|
|
|
12
13
|
const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false);
|
|
13
14
|
addHook((code, filename) => {
|
|
14
15
|
getProcessInfo().files.push(filename);
|
|
16
|
+
saveLineLengths(filename, code);
|
|
15
17
|
return code;
|
|
16
|
-
}, {
|
|
18
|
+
}, {
|
|
19
|
+
exts: ['.js', '.cjs', '.ts', '.cts', '.jsx', '.tsx'],
|
|
20
|
+
matcher: filename => !exclude.test(filename),
|
|
21
|
+
});
|
|
17
22
|
};
|
|
18
23
|
//# sourceMappingURL=register-cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-cjs.js","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"register-cjs.js","sourceRoot":"","sources":["../../lib/register-cjs.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;AACjE,MAAM,CAAC,GAAG,MAET,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,IAAI,CAAC,CAAC,YAAY,CAAC;QAAE,OAAM;IAC3B,CAAC,CAAC,YAAY,CAAC,GAAG,IAAI,CAAA;IACtB,wDAAwD;IACxD,MAAM,OAAO,GAAG,UAAU,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAA;IAChE,OAAO,CACL,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;QACjB,cAAc,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACrC,eAAe,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC,EACD;QACE,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACpD,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC7C,CACF,CAAA;AACH,CAAC,CAAA","sourcesContent":["// commonjs style loader hook, modifying require.extensions\nimport { addHook } from 'pirates'\nimport { getExclude } from './get-exclude.js'\nimport { getProcessInfo } from './get-process-info.js'\nimport { saveLineLengths } from './line-lengths.js'\n\nconst kRegisterCJS = Symbol.for('@tapjs/processinfo.registerCJS')\nconst g = global as typeof globalThis & {\n [kRegisterCJS]?: boolean\n}\n\nexport const register = () => {\n if (g[kRegisterCJS]) return\n g[kRegisterCJS] = true\n // by default we include everything in processInfo.files\n const exclude = getExclude('_TAPJS_PROCESSINFO_EXCLUDE_', false)\n addHook(\n (code, filename) => {\n getProcessInfo().files.push(filename)\n saveLineLengths(filename, code)\n return code\n },\n {\n exts: ['.js', '.cjs', '.ts', '.cts', '.jsx', '.tsx'],\n matcher: filename => !exclude.test(filename),\n }\n )\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"register-coverage.d.ts","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":";AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAG3D,eAAO,IAAI,OAAO,EAAE,OAAO,GAAG,SAAqB,CAAA;AAiDnD,eAAO,MAAM,QAAQ,YAYpB,CAAA;AAGD,eAAO,MAAM,oBAAoB,QAC1B,MAAM,eACE,mBAAmB,SAyDjC,CAAA"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// start tracking coverage, unless disabled explicltly
|
|
2
2
|
// export so that we know to collect at the end of the process
|
|
3
3
|
const enabled = process.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0';
|
|
4
|
-
import { mkdirSync,
|
|
4
|
+
import { mkdirSync, writeFileSync } from 'fs';
|
|
5
5
|
import { Session } from 'inspector';
|
|
6
6
|
import { findSourceMap } from 'module';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import { getExclude } from './get-exclude.js';
|
|
9
|
+
import { getLineLengths } from './line-lengths.js';
|
|
9
10
|
export let SESSION = undefined;
|
|
10
11
|
// NB: coverage exclusion is in addition to processinfo
|
|
11
12
|
// exclusion. Only show coverage for a file we care
|
|
@@ -16,7 +17,10 @@ const exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_');
|
|
|
16
17
|
// that pass the exclusion RegExp filter. If included in this list,
|
|
17
18
|
// then coverage will be recorded, even if it matches exclude.
|
|
18
19
|
const cfEnv = process.env._TAPJS_PROCESSINFO_COV_FILES_ || '';
|
|
19
|
-
const coveredFiles = cfEnv
|
|
20
|
+
const coveredFiles = cfEnv
|
|
21
|
+
.trim()
|
|
22
|
+
.split('\n')
|
|
23
|
+
.filter(f => !!f);
|
|
20
24
|
const fileCovered = (f, s, files = []) => {
|
|
21
25
|
const testFiles = [f];
|
|
22
26
|
if (s) {
|
|
@@ -59,16 +63,6 @@ export const register = () => {
|
|
|
59
63
|
});
|
|
60
64
|
};
|
|
61
65
|
/* c8 ignore stop */
|
|
62
|
-
// NB: this is the *generated* line lengths, not the source
|
|
63
|
-
const lineLengths = (f) => {
|
|
64
|
-
try {
|
|
65
|
-
const content = readFileSync(f, 'utf8');
|
|
66
|
-
return content.split(/\n|\u2028|\u2029/).map(l => l.length);
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return [];
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
66
|
export const coverageOnProcessEnd = (cwd, processInfo) => {
|
|
73
67
|
// Similar to the coverage tracking bootstrap problem above, c8
|
|
74
68
|
// doesn't see that this function runs, even though it DOES see
|
|
@@ -106,7 +100,7 @@ export const coverageOnProcessEnd = (cwd, processInfo) => {
|
|
|
106
100
|
if (s) {
|
|
107
101
|
const { payload } = s;
|
|
108
102
|
sourceMapCache[obj.url] = Object.assign(Object.create(null), {
|
|
109
|
-
lineLengths:
|
|
103
|
+
lineLengths: getLineLengths(f),
|
|
110
104
|
data: payload,
|
|
111
105
|
});
|
|
112
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAChE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"register-coverage.js","sourceRoot":"","sources":["../../lib/register-coverage.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,8DAA8D;AAC9D,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,GAAG,CAAA;AAChE,OAAO,EAAE,SAAS,EAAgB,aAAa,EAAE,MAAM,IAAI,CAAA;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAA+B,MAAM,QAAQ,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAA;AAEhD,MAAM,CAAC,IAAI,OAAO,GAAwB,SAAS,CAAA;AAEnD,uDAAuD;AACvD,oDAAoD;AACpD,qDAAqD;AACrD,MAAM,OAAO,GAAG,UAAU,CAAC,iCAAiC,CAAC,CAAA;AAE7D,4DAA4D;AAC5D,gEAAgE;AAChE,mEAAmE;AACnE,8DAA8D;AAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,6BAA6B,IAAI,EAAE,CAAA;AAC7D,MAAM,YAAY,GAAa,KAAK;KACjC,IAAI,EAAE;KACN,KAAK,CAAC,IAAI,CAAC;KACX,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACnB,MAAM,WAAW,GAAG,CAClB,CAAS,EACT,CAAoB,EACpB,QAAkB,EAAE,EACpB,EAAE;IACF,MAAM,S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ACb;YACD,IAAI,CAAC,EAAE;gBACL,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAA;gBACrB,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,WAAW,EAAE,cAAc,CAAC,CAAC,CAAC;oBAC9B,IAAI,EAAE,OAAO;iBACd,CAAC,CAAA;aACH;YACD,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;QAEF,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7D,qBAAqB;IACvB,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,oBAAoB","sourcesContent":["// start tracking coverage, unless disabled explicltly\n// export so that we know to collect at the end of the process\nconst enabled = process.env._TAPJS_PROCESSINFO_COVERAGE_ !== '0'\nimport { mkdirSync, readFileSync, writeFileSync } from 'fs'\nimport { Session } from 'inspector'\nimport { findSourceMap, SourceMap, SourceMapPayload } from 'module'\nimport { fileURLToPath } from 'url'\nimport { getExclude } from './get-exclude.js'\nimport { ProcessInfoNodeData } from './get-process-info.js'\nimport {getLineLengths} from './line-lengths.js'\n\nexport let SESSION: Session | undefined = undefined\n\n// NB: coverage exclusion is in addition to processinfo\n// exclusion. Only show coverage for a file we care\n// about at least somewhat, but coverage is a subset.\nconst exclude = getExclude('_TAPJS_PROCESSINFO_COV_EXCLUDE_')\n\n// This is a \\n delimited list of files to show coverage for\n// If not set, or empty, then coverage is included for all files\n// that pass the exclusion RegExp filter. If included in this list,\n// then coverage will be recorded, even if it matches exclude.\nconst cfEnv = process.env._TAPJS_PROCESSINFO_COV_FILES_ || ''\nconst coveredFiles: string[] = cfEnv\n .trim()\n .split('\\n')\n .filter(f => !!f)\nconst fileCovered = (\n f: string,\n s?: SourceMapPayload,\n files: string[] = []\n) => {\n const testFiles = [f]\n if (s) {\n for (const src of s.sources || []) {\n testFiles.push(fileURLToPath(src))\n }\n }\n if (!testFiles.some(f => files.includes(f))) return false\n\n // if at least one of them are explicitly covered, then include it,\n // otherwise omit if we explicitly listed\n if (coveredFiles.length) {\n return testFiles.some(f => coveredFiles.includes(f))\n }\n\n for (const f of testFiles) {\n if (!exclude.test(f)) return true\n }\n return false\n}\n\n// C8 can't see that this function runs, best theory is that it\n// collides with what it's doing with the coverage it's collecting\n// This ignore can possibly be removed once this is being tested\n// with a version of tap that uses this library, but it might just\n// be an unresolveable bootstrap problem.\n// The test does verify that it ran, because otherwise, there would\n// be no coverage, and it verifies that it gets the expected coverage.\n/* c8 ignore start */\nexport const register = () => {\n if (!enabled) return\n process.env._TAPJS_PROCESSINFO_COVERAGE_ = '1'\n\n SESSION = new Session()\n SESSION.connect()\n SESSION.post('Profiler.enable')\n SESSION.post('Runtime.enable')\n SESSION.post('Profiler.startPreciseCoverage', {\n callCount: true,\n detailed: true,\n })\n}\n/* c8 ignore stop */\n\nexport const coverageOnProcessEnd = (\n cwd: string,\n processInfo: ProcessInfoNodeData\n) => {\n // Similar to the coverage tracking bootstrap problem above, c8\n // doesn't see that this function runs, even though it DOES see\n // that the function defined below runs, which is weird.\n /* c8 ignore start */\n if (!SESSION) return\n const session = SESSION\n\n const f = `${cwd}/.tap/coverage/${processInfo.uuid}.json`\n mkdirSync(`${cwd}/.tap/coverage`, { recursive: true })\n\n session.post('Profiler.takePreciseCoverage', (er, cov) => {\n session.post('Profiler.stopPreciseCoverage')\n /* c8 ignore stop */\n\n // something very strange and bad happened\n /* c8 ignore start */\n if (er) {\n throw er\n }\n /* c8 ignore stop */\n\n // Create a source-map-cache that c8 uses in report generation\n const sourceMapCache: {\n [k: string]: {\n lineLengths: number[]\n data: SourceMapPayload\n }\n } = {}\n Object.assign(cov, {\n 'source-map-cache': sourceMapCache,\n })\n\n cov.result = cov.result.filter(obj => {\n if (!/^file:/.test(obj.url)) {\n return false\n }\n const f = fileURLToPath(obj.url)\n // see if it has a source map\n const s = findSourceMap(f)\n if (!fileCovered(f, s?.payload, processInfo.files)) {\n return false\n }\n if (s) {\n const { payload } = s\n sourceMapCache[obj.url] = Object.assign(Object.create(null), {\n lineLengths: getLineLengths(f),\n data: payload,\n })\n }\n return true\n })\n\n writeFileSync(f, JSON.stringify(cov, null, 2) + '\\n', 'utf8')\n /* c8 ignore start */\n })\n}\n/* c8 ignore stop */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-env.d.ts","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"register-env.d.ts","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,QAAQ,YAQpB,CAAA"}
|
package/dist/mjs/register-env.js
CHANGED
|
@@ -5,14 +5,16 @@ const { hasOwnProperty } = Object.prototype;
|
|
|
5
5
|
const getEnvs = (env) => {
|
|
6
6
|
// load it here so that it isn't cached before the loader attaches
|
|
7
7
|
// in self-test scenario.
|
|
8
|
-
|
|
9
|
-
return Object.fromEntries(Object.entries(
|
|
10
|
-
.filter(([k]) => !hasOwnProperty.call(env
|
|
11
|
-
.concat([
|
|
8
|
+
// copy all of OUR envs, if not specifically set on the env object
|
|
9
|
+
return Object.fromEntries(Object.entries(process.env)
|
|
10
|
+
.filter(([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k))
|
|
11
|
+
.concat([
|
|
12
|
+
['NODE_OPTIONS', nodeOptionsEnv(process.env, process.execArgv)],
|
|
13
|
+
]));
|
|
12
14
|
};
|
|
13
15
|
export const register = () => {
|
|
14
16
|
processOnSpawn.addListener(obj => {
|
|
15
|
-
obj.env = Object.assign(obj.env || {}, getEnvs(obj.env));
|
|
17
|
+
obj.env = Object.assign(obj.env || { ...process.env }, getEnvs(obj.env));
|
|
16
18
|
return obj;
|
|
17
19
|
});
|
|
18
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register-env.js","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,KAAK,GAAG,sBAAsB,CAAA;AACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,CAAA;AAE3C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE;IAC1C,kEAAkE;IAClE,yBAAyB;IACzB,
|
|
1
|
+
{"version":3,"file":"register-env.js","sourceRoot":"","sources":["../../lib/register-env.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAEtD,MAAM,KAAK,GAAG,sBAAsB,CAAA;AACpC,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC,SAAS,CAAA;AAE3C,MAAM,OAAO,GAAG,CAAC,GAAuB,EAAE,EAAE;IAC1C,kEAAkE;IAClE,yBAAyB;IACzB,kEAAkE;IAClE,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC;SACxB,MAAM,CACL,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAChE;SACA,MAAM,CAAC;QACN,CAAC,cAAc,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;KAChE,CAAC,CACL,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE;QAC/B,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CACrB,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,EAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CACjB,CAAA;QACD,OAAO,GAAG,CAAA;IACZ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import processOnSpawn from 'process-on-spawn'\nimport { nodeOptionsEnv } from './node-options-env.js'\n\nconst envRE = /^_TAPJS_PROCESSINFO_/\nconst { hasOwnProperty } = Object.prototype\n\nconst getEnvs = (env?: NodeJS.ProcessEnv) => {\n // load it here so that it isn't cached before the loader attaches\n // in self-test scenario.\n // copy all of OUR envs, if not specifically set on the env object\n return Object.fromEntries(\n Object.entries(process.env)\n .filter(\n ([k]) => !(env && hasOwnProperty.call(env, k)) && envRE.test(k)\n )\n .concat([\n ['NODE_OPTIONS', nodeOptionsEnv(process.env, process.execArgv)],\n ])\n )\n}\n\nexport const register = () => {\n processOnSpawn.addListener(obj => {\n obj.env = Object.assign(\n obj.env || { ...process.env },\n getEnvs(obj.env)\n )\n return obj\n })\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapjs/processinfo",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"types": "./dist/cjs/index.d.ts",
|
|
6
6
|
"module": "./dist/mjs/esm.mjs",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"tap": "^16.3.0",
|
|
86
86
|
"ts-node": "^10.9.1",
|
|
87
87
|
"typedoc": "^0.24.8",
|
|
88
|
-
"typescript": "^5.
|
|
88
|
+
"typescript": "^5.1.3"
|
|
89
89
|
},
|
|
90
90
|
"repository": "https://github.com/tapjs/processinfo"
|
|
91
91
|
}
|