{"name":"@tapjs/processinfo","version":"3.1.12","type":"module","main":"./dist/commonjs/index.js","types":"./dist/commonjs/index.d.ts","tshy":{"main":true,"selfLink":false,"exports":{".":"./src/index.ts","./loader":"./src/loader-legacy.mts","./import":"./src/import.mts"}},"exports":{".":{"import":{"source":"./src/index.ts","types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"source":"./src/index.ts","types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./loader":{"import":{"source":"./src/loader-legacy.mts","types":"./dist/esm/loader-legacy.d.mts","default":"./dist/esm/loader-legacy.mjs"}},"./import":{"import":{"source":"./src/import.mts","types":"./dist/esm/import.d.mts","default":"./dist/esm/import.mjs"}}},"scripts":{"preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","preprepare":"rm -rf dist","prepare":"tshy","pretest":"npm run prepare","presnap":"npm run prepare","test":"tap","snap":"tap","format":"prettier --write . --log-level warn","typedoc":"typedoc --tsconfig .tshy/esm.json ./src/*.ts ./src/*.mts"},"tap":{"coverage":false,"node-arg":["--enable-source-maps","--no-warnings","--require","ts-node/register"],"test-env":["TS_NODE_PROJECT=tsconfig/test.json","_TAPJS_PROCESSINFO_EXCLUDE_=/.*[\\/\\\\]test-processinfo-exclude.js$/"],"ts":false,"test-regex":"test/.*\\.[mc]?[jt]s$"},"dependencies":{"node-options-to-argv":"^1.0.0","pirates":"^4.0.5","process-on-spawn":"^1.0.0","signal-exit":"^4.0.2","uuid":"^14.0.0"},"engines":{"node":">=16.17"},"license":"BlueOak-1.0.0","devDependencies":{"@npmcli/promise-spawn":"^2.0.1","@types/node":"^25.7.0","@types/npmcli__promise-spawn":"^6.0.0","@types/tap":"^15.0.8","@types/uuid":"^9.0.1","diff":"^5.0.0","prettier":"^3.6.2","sync-content":"^1.0.2","tap":"^16.3.9","ts-node":"^10.9.1","tshy":"^1.11.1","typedoc":"^0.28.14","typescript":"^5.2.2"},"repository":{"type":"git","url":"git+https://github.com/tapjs/processinfo.git"},"module":"./dist/esm/index.js","gitHead":"8547ca4ccc462474ff08e1bf7f9e8fb5cff3e7a1","_id":"@tapjs/processinfo@3.1.12","description":"A Node.js loader to track processes and which JavaScript files they load.","bugs":{"url":"https://github.com/tapjs/processinfo/issues"},"homepage":"https://github.com/tapjs/processinfo#readme","_nodeVersion":"26.0.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-ZkYxCTEDL2ZEvvPHyZK1kvqm1t5mjRrwaGKRGFAhKh/qqaSSklk7fasqpX6fE4XLYpGf4J01C/sMztz+DkY0dg==","shasum":"b1fb7444a05aa24d59e842c5cc111455fdf04a6a","tarball":"http://registry-npm.ywwl.com/@tapjs/processinfo/download/@tapjs/processinfo-3.1.12.tgz","fileCount":197,"unpackedSize":416771,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDc86grhhJe+XEkZlu0WfnLuDGtI3bTsHZ0tgooDWkmtwIgcnRcX6doIMck7jnpRVRNAvCQazrq5W/LgtfDsdZX9D4="}],"size":60632,"noattachment":false,"key":"/@tapjs/processinfo/-/@tapjs/processinfo-3.1.12.tgz"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/processinfo_3.1.12_1778873099095_0.12126057579951066"},"_hasShrinkwrap":false,"readme":"# @tapjs/processinfo\n\nA Node.js loader to track processes and which JavaScript files they load.\n\nAfter the process has run, all wrapped process info is dumped to\n`.tap/processinfo`.\n\nThe exported object can also be used to spawn processes, clear the\nprocessinfo data, or load the processinfo data.\n\n## USAGE\n\nRun the top level process with a `--loader` or `--require` argument to\ntrack all Node.js child processes.\n\n```sh\n# wrap both CommonJS and ESM, node versions less than 20.6\nnode --loader=@tapjs/processinfo/loader file.js\n\n# for node versions 20.6 and higher:\nnode --import=@tapjs/processinfo/import\n```\n\nTo spawn a wrapped process from JavaScript, you can run:\n\n```js\nimport {\n  spawn,\n  exec,\n  execFile,\n  execSync,\n  execFileSync,\n  fork,\n} from '@tapjs/processinfo'\n// any of these will work\nconst childProcess = spawn(cmd, args, options)\nconst childProcess = exec(cmd, options, callback)\nconst childProcess = execFile(cmd, options, callback)\nconst childProcess = spawnSync(cmd, args, options)\nconst childProcess = execSync(cmd, options)\nconst childProcess = execFileSync(cmd, options)\nconst childProcess = fork(cmd, options)\n```\n\nThe `cmd` and `args` parameters are identical to the methods from the\nNode.js `child_process` module. The `options` parameter is also identical,\nbut may also include an `externalID` field, which if set to a string, will\nbe used as the processinfo `externalID`.\n\nIf you just use the normal `spawn`/`exec` methods from the Node.js\n`child_process` module, then the relevant environment variables will still\nbe tracked, unless explicitly set to `''` or some other value.\n\n### Important\n\nIn order to properly track `lineLengths` (required for coverage\nreporting on source mapped files), `@tapjs/processinfo` must be\nthe **last** loader specified on the command line, so that it can\nget access to the transpiled source that Node.js actually\nexecutes.\n\n### Interacting with Process Info\n\nTo load the process info data, use the exported `ProcessInfo` class.\n\n```js\nimport { ProcessInfo } from '@tapjs/processinfo'\n\n// returns\n// {\n//   roots: Set([ProcessInfo.Node, ...]) for each root process group\n//   files: Map({ filename => Set([ProcessInfo.Node, ...]) }),\n//   externalIDs: Map({ externalID => ProcessInfo.Node }),\n//   uuids: Map({ uuid => ProcessInfo.Node }),\n// }\n// A ProcessInfo.Node looks like:\n// {\n//   date: iso date string,\n//   argv,\n//   execArgv,\n//   cwd,\n//   pid,\n//   ppid,\n//   uuid,\n//   externalID,\n//   parent: <ProcessInfo.Node or null for root node>,\n//   root: <ProcessInfo.Node>,\n//   children: [ProcessInfo.Node, ...],\n//   descendants: [ProcessInfo.Node, ...],\n//   files: [ filename, ... ],\n//   code: unix exit code,\n//   signal: terminating signal or null,\n//   runtime: high resolution run time in ms,\n// }\nconst processInfoDB = await ProcessInfo.load()\n// say we wanted to find all the files loaded by the process 'foo'\nconst proc = processInfoDB.externalIDs.get('foo')\nconsole.error(`Files loaded by process named 'foo':`, proc.files)\n\n// now let's find all any other named processes that loaded them\nfor (const f of proc.files) {\n  for (const otherProc of processInfoDB.files.get(f)) {\n    // walk up the tree looking for a named process\n    for (let parent = otherProc; parent; parent = parent.parent) {\n      if (parent.externalID && parent !== proc) {\n        console.error(`Also loaded by process ${parent.externalID}`)\n      }\n    }\n  }\n}\n```\n\nNote: unless there has been a previous wrapped process run, nothing will be\npresent in the data. That is, `data.root` will be null, and all the maps\nwill be empty.\n\n## Controlling Coverage\n\nTo disable coverage entirely, set\n`_TAPJS_PROCESSINFO_COVERAGE_=0` in the environment.\n\nTo exclude certain file paths from coverage with a pattern, set\nthe `_TAPJS_PROCESSINFO_COV_EXCLUDE_` to a regular expression\nstring. Note that processinfo will _never_ provide coverage for a\nfile that's excluded from process file tracking.\n\nTo exclude specific individual file paths from coverage, set the\n`_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_` to a `\\n` delimited\nset of file paths.\n\nTo include only a specific set of files for coverage (as with\nnode-tap's `coverage-map` option), set\n`_TAPJS_PROCESSINFO_COV_FILES_` to a `\\n` delimited list of the\nfiles to include. These will have their coverage reported even if\nthey would be excluded by the `_TAPJS_PROCESSINFO_COV_EXCLUDE_`\nregexp or `_TAPJS_PROCESSINFO_COV_EXCLUDE_FILES_` list.\n\nNote that coverage _instrumentation_ is by necessity enabled for\nall files, but it's only written to disk if the file (or any of\nits sources, if it has a sourcemap) is included.\n","publish_time":1778873099263,"_cnpm_publish_time":1778873099263,"dist-tags":{"latest":"3.1.12"}}