{"name":"@tapjs/processinfo","version":"3.1.9","license":"BlueOak-1.0.0","_id":"@tapjs/processinfo@3.1.9","maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"isaacs","email":"i@izs.me"}],"homepage":"https://github.com/tapjs/processinfo#readme","bugs":{"url":"https://github.com/tapjs/processinfo/issues"},"tap":{"ts":false,"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$/"],"test-regex":"test/.*\\.[mc]?[jt]s$"},"dist":{"shasum":"d313f07c8e6643713e1e1d1b94ab1acc20757e36","tarball":"http://registry-npm.ywwl.com/@tapjs/processinfo/download/@tapjs/processinfo-3.1.9.tgz","fileCount":197,"integrity":"sha512-yIbYH9ROI5m5F2B5Hpk6t89OkHBrDbL3qncPO9OfPuSvJsvAIDG91I0hxGQNohdaxmqz5L4QiIYc5Y0KmtLzCQ==","signatures":[{"sig":"MEUCIQDzSFmpYWoONkMujKQaqst3Qvy1iDw5I8HVoE9tJzpOlQIgI2QUIo7ns7jNwzmOvIgc8enIg51ab1bOwu6kQHxkUUA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":410358,"size":59774,"noattachment":false,"key":"/@tapjs/processinfo/-/@tapjs/processinfo-3.1.9.tgz"},"main":"./dist/commonjs/index.js","tshy":{"main":true,"exports":{".":"./src/index.ts","./import":"./src/import.mts","./loader":"./src/loader-legacy.mts"},"selfLink":false},"type":"module","types":"./dist/commonjs/index.d.ts","engines":{"node":">=16.17"},"exports":{".":{"import":{"types":"./dist/esm/index.d.ts","default":"./dist/esm/index.js"},"require":{"types":"./dist/commonjs/index.d.ts","default":"./dist/commonjs/index.js"}},"./import":{"import":{"types":"./dist/esm/import.d.mts","default":"./dist/esm/import.mjs"}},"./loader":{"import":{"types":"./dist/esm/loader-legacy.d.mts","default":"./dist/esm/loader-legacy.mjs"}}},"gitHead":"fef606f0176e478ddf0ce8a476c7a1da83bf22ed","scripts":{"snap":"c8 tap","test":"c8 tap","format":"prettier --write . --log-level warn","prepare":"tshy","presnap":"npm run prepare","pretest":"npm run prepare","typedoc":"typedoc --tsconfig .tshy/esm.json ./src/*.ts ./src/*.mts","preprepare":"rm -rf dist","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags"},"_npmUser":{"name":"isaacs","email":"i@izs.me"},"repository":{"url":"git+https://github.com/tapjs/processinfo.git","type":"git"},"_npmVersion":"11.6.3","description":"A Node.js loader to track processes and which JavaScript files they load.","directories":{},"_nodeVersion":"24.4.1","dependencies":{"uuid":"^8.3.2","pirates":"^4.0.5","signal-exit":"^4.0.2","process-on-spawn":"^1.0.0","node-options-to-argv":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^7.13.0","tap":"^16.3.9","diff":"^5.0.0","tshy":"^1.11.1","ts-node":"^10.9.1","typedoc":"^0.28.14","prettier":"^3.6.2","@types/tap":"^15.0.8","typescript":"^5.2.2","@types/node":"^20.1.2","@types/uuid":"^9.0.1","sync-content":"^1.0.2","@npmcli/promise-spawn":"^2.0.1","@types/npmcli__promise-spawn":"^6.0.0"},"_npmOperationalInternal":{"tmp":"tmp/processinfo_3.1.9_1764193221643_0.9423962974728504","host":"s3://npm-registry-packages-npm-production"},"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":1764193221848,"_cnpm_publish_time":1764193221848,"dist-tags":{"latest":"3.1.12"}}