{"id":15290150,"url":"https://github.com/npm/promise-spawn","last_synced_at":"2025-05-16T08:05:38.199Z","repository":{"id":40525006,"uuid":"246110676","full_name":"npm/promise-spawn","owner":"npm","description":"spawn processes the way the npm cli likes to do","archived":false,"fork":false,"pushed_at":"2025-04-28T18:56:56.000Z","size":210,"stargazers_count":20,"open_issues_count":3,"forks_count":14,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-05-03T00:42:59.352Z","etag":null,"topics":["npm-cli"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-03-09T18:21:57.000Z","updated_at":"2025-04-28T18:56:58.000Z","dependencies_parsed_at":"2023-12-21T19:44:28.981Z","dependency_job_id":"fd614ebc-d63a-43e9-a7ca-fb9fad50c6da","html_url":"https://github.com/npm/promise-spawn","commit_stats":{"total_commits":121,"total_committers":12,"mean_commits":"10.083333333333334","dds":0.71900826446281,"last_synced_commit":"81de91de507d73e69813a96091ce9fdcd64dece7"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fpromise-spawn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fpromise-spawn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fpromise-spawn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Fpromise-spawn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/promise-spawn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036838,"owners_count":22003662,"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":["npm-cli"],"created_at":"2024-09-30T16:05:41.474Z","updated_at":"2025-05-16T08:05:33.183Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @npmcli/promise-spawn\n\nSpawn processes the way the npm cli likes to do.  Give it some options,\nit'll give you a Promise that resolves or rejects based on the results of\nthe execution.\n\n## USAGE\n\n```js\nconst promiseSpawn = require('@npmcli/promise-spawn')\n\npromiseSpawn('ls', [ '-laF', 'some/dir/*.js' ], {\n  cwd: '/tmp/some/path', // defaults to process.cwd()\n  stdioString: true, // stdout/stderr as strings rather than buffers\n  stdio: 'pipe', // any node spawn stdio arg is valid here\n  // any other arguments to node child_process.spawn can go here as well,\n}, {\n  extra: 'things',\n  to: 'decorate',\n  the: 'result',\n}).then(result =\u003e {\n  // {code === 0, signal === null, stdout, stderr, and all the extras}\n  console.log('ok!', result)\n}).catch(er =\u003e {\n  // er has all the same properties as the result, set appropriately\n  console.error('failed!', er)\n})\n```\n\n## API\n\n### `promiseSpawn(cmd, args, opts, extra)` -\u003e `Promise`\n\nRun the command, return a Promise that resolves/rejects based on the\nprocess result.\n\nResult or error will be decorated with the properties in the `extra`\nobject.  You can use this to attach some helpful info about _why_ the\ncommand is being run, if it makes sense for your use case.\n\nIf `stdio` is set to anything other than `'inherit'`, then the result/error\nwill be decorated with `stdout` and `stderr` values.  If `stdioString` is\nset to `true`, these will be strings.  Otherwise they will be Buffer\nobjects.\n\nReturned promise is decorated with the `stdin` stream if the process is set\nto pipe from `stdin`.  Writing to this stream writes to the `stdin` of the\nspawned process.\n\n#### Options\n\n- `stdioString` Boolean, default `true`.  Return stdout/stderr output as\n  strings rather than buffers.\n- `cwd` String, default `process.cwd()`.  Current working directory for\n  running the script.  Also the argument to `infer-owner` to determine\n  effective uid/gid when run as root on Unix systems.\n- `shell` Boolean or String. If false, no shell is used during spawn. If true,\n  the system default shell is used. If a String, that specific shell is used.\n  When a shell is used, the given command runs from within that shell by\n  concatenating the command and its escaped arguments and running the result.\n  This option is _not_ passed through to `child_process.spawn`.\n- Any other options for `child_process.spawn` can be passed as well.\n\n### `promiseSpawn.open(arg, opts, extra)` -\u003e `Promise`\n\nUse the operating system to open `arg` with a default program. This is useful\nfor things like opening the user's default browser to a specific URL.\n\nDepending on the platform in use this will use `start` (win32), `open` (darwin)\nor `xdg-open` (everything else). In the case of Windows Subsystem for Linux we\nuse the default win32 behavior as it is much more predictable to open the arg\nusing the host operating system.\n\n#### Options\n\nOptions are identical to `promiseSpawn` except for the following:\n\n- `command` String, the command to use to open the file in question. Default is\n   one of `start`, `open` or `xdg-open` depending on platform in use.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fpromise-spawn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Fpromise-spawn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Fpromise-spawn/lists"}