{"id":22184439,"url":"https://github.com/ksxnodemodules/advanced-spawn-async","last_synced_at":"2026-05-06T23:32:02.368Z","repository":{"id":33026757,"uuid":"150256876","full_name":"ksxnodemodules/advanced-spawn-async","owner":"ksxnodemodules","description":"Advanced isomorphic asynchronous spawn function","archived":false,"fork":false,"pushed_at":"2023-01-09T13:00:37.000Z","size":268,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T04:02:50.486Z","etag":null,"topics":["async","asynchronous","child-process","isomorphic","javascript","nodejs","spawn","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/advanced-spawn-async","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ksxnodemodules.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"khai96_","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-09-25T11:47:47.000Z","updated_at":"2022-07-10T11:32:50.000Z","dependencies_parsed_at":"2023-01-14T23:06:43.478Z","dependency_job_id":null,"html_url":"https://github.com/ksxnodemodules/advanced-spawn-async","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksxnodemodules%2Fadvanced-spawn-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksxnodemodules%2Fadvanced-spawn-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksxnodemodules%2Fadvanced-spawn-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ksxnodemodules%2Fadvanced-spawn-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ksxnodemodules","download_url":"https://codeload.github.com/ksxnodemodules/advanced-spawn-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245336138,"owners_count":20598622,"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":["async","asynchronous","child-process","isomorphic","javascript","nodejs","spawn","typescript"],"created_at":"2024-12-02T10:13:03.574Z","updated_at":"2026-05-06T23:31:57.324Z","avatar_url":"https://github.com/ksxnodemodules.png","language":"TypeScript","funding_links":["https://patreon.com/khai96_"],"categories":[],"sub_categories":[],"readme":"# advanced-spawn-async\n\nAdvanced isomorphic asynchronous spawn function\n\n## Requirements\n\n* Node.js ≥ 8.9.0\n\n## Usage\n\n### Basic Usage\n\nUsage without custom `spawn` function (i.e. Use built-in `child_process.spawn`).\n\n```javascript\nimport spawn from 'advanced-spawn-async'\n\nconst {\n  process, // ChildProcess\n  onclose, // Promise\u003c{ command, args, options, stdout, stderr, output, status, signal, process }\u003e\n  onexit // Promise\u003c{ command, args, options, stdout, stderr, output, status, signal, process }\u003e\n} = spawn('node')\n\nprocess.stdin.write('console.info(\"stdout\")\\n')\nprocess.stdin.write('console.error(\"stderr\")\\n')\nprocess.stdin.end('require(\"process\").exit(0)\\n')\n\nonclose.then(({ stdout, stderr, output }) =\u003e {\n  console.log('CLOSE', { stdout, stderr, output })\n})\n\nonexit.then(({ stdout, stderr, output }) =\u003e {\n  console.log('EXIT', { stdout, stderr, output })\n})\n```\n\n**Sample Output:**\n\n```javascript\nEXIT {\n  stdout: 'stdout\\n',\n  stderr: 'stderr\\n',\n  output: 'stdout\\nstderr\\n'\n}\nCLOSE {\n  stdout: 'stdout\\n',\n  stderr: 'stderr\\n',\n  output: 'stdout\\nstderr\\n'\n}\n```\n\n### Custom Spawn Function\n\nUser provide custom spawn function.\n\n```javascript\nimport { core } from 'advanced-spawn-async'\nimport spawn from 'cross-spawn'\n\nconst { process, onclose, onexit } = core(spawn, 'node')\n\n// The rest is like the above example\n```\n\n### Provide Arguments and Options\n\n```javascript\nimport spawn from 'advanced-spawn-async'\nconst { onclose } = spawn('echo', ['hello'], { stdio: 'inherit', event: 'close' })\nonclose.then(status =\u003e console.log({status}))\n```\n\n### Non-Zero Status Code\n\nWhen process returns non-zero code.\n\n```javascript\nimport spawn from 'advanced-spawn-async'\nconst { process, onclose } = spawn('node', [], { event: 'close' })\nprocess.stdin.end('process.exit(123)\\n')\nonclose.catch(error =\u003e console.log(error.info))\n```\n\n## License\n\n[MIT](https://git.io/fAAID) © [Hoàng Văn Khải](https://github.com/KSXGitHub)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksxnodemodules%2Fadvanced-spawn-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksxnodemodules%2Fadvanced-spawn-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksxnodemodules%2Fadvanced-spawn-async/lists"}