{"id":15417561,"url":"https://github.com/kenotron/capturing-inherit","last_synced_at":"2025-12-26T12:30:13.368Z","repository":{"id":145446301,"uuid":"504908052","full_name":"kenotron/capturing-inherit","owner":"kenotron","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-18T17:45:18.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-29T14:49:28.160Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kenotron.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-18T17:27:29.000Z","updated_at":"2022-06-18T17:27:38.000Z","dependencies_parsed_at":"2023-05-30T02:45:12.858Z","dependency_job_id":null,"html_url":"https://github.com/kenotron/capturing-inherit","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"92df7ee3d90250739b303af6bcaaa905d1b049f8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenotron%2Fcapturing-inherit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenotron%2Fcapturing-inherit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenotron%2Fcapturing-inherit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kenotron%2Fcapturing-inherit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kenotron","download_url":"https://codeload.github.com/kenotron/capturing-inherit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239711472,"owners_count":19684605,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T17:16:10.074Z","updated_at":"2025-12-26T12:30:13.305Z","avatar_url":"https://github.com/kenotron.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# How to capture a child_process's inherit outputs\nhttps://twitter.com/kenneth_chau/status/1538216216572985346?s=20\u0026t=95R6BkA_EqXiN52s06x7ig\n\n## 1. fork a `runner.js` w/ `stdio: pipe` + add `on('data')` handler\n\n```js\nconst forked = fork(\"runner.js\", {\n  stdio: [\"ignore\", \"pipe\", \"pipe\", \"ipc\"],\n});\n```\n\n## 2. `runner.js`, in turn executes a command (even `child_process` spawn or exec with inherit)\n```js\nexecSync(`npm run test`, {\n  stdio: [\"inherit\", \"inherit\", \"inherit\"],\n  env: process.env,\n});\n```\n\n## 3. Capture output from pipe: `index.js`\n\n```js\nlet msgs = [];\n\nforked.stdout.on(\"data\", (data) =\u003e {\n  msgs.push(data);\n});\n\nforked.on(\"exit\", (code, signal) =\u003e {\n  console.log(`${msgs.join(\"\")}`);\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenotron%2Fcapturing-inherit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkenotron%2Fcapturing-inherit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkenotron%2Fcapturing-inherit/lists"}