{"id":19478893,"url":"https://github.com/xan105/node-shell","last_synced_at":"2026-04-30T12:32:25.142Z","repository":{"id":232214170,"uuid":"783759392","full_name":"xan105/node-shell","owner":"xan105","description":"Run external command or script","archived":false,"fork":false,"pushed_at":"2024-04-29T10:39:24.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T16:44:39.013Z","etag":null,"topics":["child-process","exec","node","shell"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/xan105.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":"xan105","custom":"https://www.paypal.me/xan105","patreon":"xan105"}},"created_at":"2024-04-08T14:13:33.000Z","updated_at":"2024-04-29T10:39:27.000Z","dependencies_parsed_at":"2024-04-08T17:42:44.822Z","dependency_job_id":"7f6c9c00-a9ae-4152-b67c-bdbdadf3e0bf","html_url":"https://github.com/xan105/node-shell","commit_stats":null,"previous_names":["xan105/node-shell"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xan105/node-shell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xan105","download_url":"https://codeload.github.com/xan105/node-shell/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xan105%2Fnode-shell/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32465009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["child-process","exec","node","shell"],"created_at":"2024-11-10T19:51:56.875Z","updated_at":"2026-04-30T12:32:25.122Z","avatar_url":"https://github.com/xan105.png","language":"JavaScript","funding_links":["https://github.com/sponsors/xan105","https://www.paypal.me/xan105","https://patreon.com/xan105"],"categories":[],"sub_categories":[],"readme":"About\n=====\n\nRun external command or script.\n\n📦 Scoped `@xan105` packages are for my own personal use but feel free to use them.\n\nExample\n=======\n\nRun external command and display the output\n\n```js\nimport { $ } from \"@xan105/shell\";\nconst stdout = await $(\"echo Hello World\");\nconsole.log(stdout);\n```\n\nRun pwsh cmdlet and parse the output\n\n```js\nimport { $, pwsh } from \"@xan105/shell\";\nconst stdout = await $(\"Get-StartApps | Format-List\");\nconst json = pwsh.parseList(stdout)\nconsole.log(json);\n```\n\nRun external script\n\n```js\nimport { $ } from \"@xan105/shell\";\nawait $(\"/path/to/script\", { script: true });\n```\n\nInstall\n=======\n\n```\nnpm install @xan105/shell\n```\n\nAPI\n===\n\n⚠️ This module is only available as an ECMAScript module (ESM).\n\n## Named export\n\n### `$(cmd: string, option?: object): Promise\u003cstring\u003e`\n\nRun external command or script.\n\n**⚙️ Options**\n\n - `shell?: string` (powershell/sh)\n \n    Shell to send the command/script to.\n  \n - `script?: boolean` (false)\n \n    `cmd` is considered as the script's filePath when set to `true`.\n \n - `cwd?: string` (current cwd)\n \n    Current working dir.\n    \n - `env?: { key: value, ... }` (system env)\n \n    Env. variable.\n \n - `silent?: boolean` (false)\n \n    Silent fail on error (no throw) when set to `true`\n    \n - `escape?: boolean` (true)\n\n    When set to `true`, If the specified shell has an *escape char* different than `\\`, escape it.\n\n**Return**\n\n✔️ Shell output *(stdout)*\n❌ Rejects on error\n\n## pwsh\n\n### `parseList(stdout: string, option?: object): object[]`\n\nParse a PowerShell cmdlet list formated output into a JSON like object.\n\neg: `foo | Format-List` or `foo | fl`\n\n⚙️ **Options**\n\n  - `translate?: boolean` (true)\n  \n    Auto string convertion to boolean, number, etc.\n    \nExample:\n\n```js\nimport { $ } from \"@xan105/shell\";\nimport { parseList } from \"@xan105/shell/pwsh\"\n\nconst stdout = await $(\"ls | Format-List\");\nconst json = parseList(stdout)\nconsole.log(json);\n```\n\n⚠️ **JSON compatibility**\n\nSome integers will be represented as **BigInt** due to their size when using the translate option.\u003cbr/\u003e\n**BigInt is not a valid value in the JSON spec.**\u003cbr/\u003e\nAs such when stringify-ing the returned object to JSON you'll need to handle the JSON stringify replacer function to prevent it to fail.\n\nA common workaround is to represent them as a string:\n\n```js\nJSON.stringify(data, function(key, value) {\n  if(typeof value === \"bigint\")\n    return value.toString();\n  else\n    return value;\n});\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxan105%2Fnode-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxan105%2Fnode-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxan105%2Fnode-shell/lists"}