{"id":26638030,"url":"https://github.com/spellcraftai/universal-shell","last_synced_at":"2025-04-10T19:50:46.519Z","repository":{"id":57104764,"uuid":"279491211","full_name":"SpellcraftAI/universal-shell","owner":"SpellcraftAI","description":"Cross-platform async shell support for POSIX commands on Linux, MacOS, and Windows.","archived":false,"fork":false,"pushed_at":"2023-05-25T11:39:55.000Z","size":305,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T05:54:04.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/SpellcraftAI.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}},"created_at":"2020-07-14T05:28:35.000Z","updated_at":"2025-03-27T21:04:05.000Z","dependencies_parsed_at":"2023-07-17T00:14:50.860Z","dependency_job_id":"f11b7e58-317b-4464-8a7c-6bdc9584be62","html_url":"https://github.com/SpellcraftAI/universal-shell","commit_stats":null,"previous_names":["spellcraftai/universal-shell","ctjlewis/await-shell","ctjlewis/universal-shell"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpellcraftAI%2Funiversal-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpellcraftAI%2Funiversal-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpellcraftAI%2Funiversal-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpellcraftAI%2Funiversal-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpellcraftAI","download_url":"https://codeload.github.com/SpellcraftAI/universal-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248283110,"owners_count":21077775,"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":"2025-03-24T17:24:55.780Z","updated_at":"2025-04-10T19:50:46.495Z","avatar_url":"https://github.com/SpellcraftAI.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `universal-shell`\n\nLibrary for calling POSIX-style shell commands cross-platform. Automatically\ntranslates commands for Windows support out of the box.\n\n`shell.run()` returns a Promise that will resolve or reject to an object\ncontaining process information of type `SpawnResult`:\n\n```ts\nexport interface SpawnResult {\n  code: number | null;\n  stdout: string;\n  stderr: string;\n}\n```\n\n### Pattern\n\n```ts\n/**\n * Create a new process where shells will run.\n */\nconst shell = createShell();\n\n/**\n * Read the exit code, stdout, and stderr from shell.run().\n * \n * Note: POSIX-like syntax works on Windows! See \"Specification\" below.\n */\nconst { code, stdout, stderr } = await shell.run(\"cp -rf src dest \u0026\u0026 yarn --cwd dest some-command\");\n\n/**\n * Run sequential commands.\n */\nawait shell.run(\n  \"cd dir \u0026\u0026 yarn do_stuff\",\n  \"cd otherDir \u0026\u0026 yarn do_stuff\"\n);\n```\n\n#### Override per-platform\n\nYou can override the command to run per-platform in `shell.run(...)`.\n\n```ts\nconst shell = createShell();\n\n/**\n * All process.platform types are supported, i.e. \"win32\" and \"darwin\".\n * \n * \"posix\" matches \"linux\" and \"darwin\".\n */ \nconst { code, stdout, stderr } = await shell.run({\n  win32: \"...\",\n  posix: \"...\"\n});\n```\n\n#### Custom options\n\nYou can pass custom spawn options to `createShell({ ... })`.\n\n```ts\n/**\n * Disable logging of commands and pass custom spawn options. \n */\nconst customShell = createShell({\n  log: false,\n  // Custom process.spawn() options.\n  stdio: 'inherit',\n  // ...\n});\n```\n\n## Specification\n\nThis section explains how shell command strings (like `\"cd dir/\"`) are\nsupported on Windows, as well as translations for specific commands.\n\n### Shell support\n\n| POSIX | Windows |\n| --- | --- |\n| *Detached* | *Not detached* |\n| `my-cmd [...args]` | `cmd.exe /d /s /c my-cmd [...args]` |\n\n### Specific commands\n\n| POSIX | Windows |\n| --- | --- |\n| `cp -rf [src] dest]` | `xcopy /E /S /G /Q /Y [src] [dest]` |\n| `pkill [pid]` | `taskkill /T /F /pid [pid]` |\n| `ln [link] [target]` | `mklink [link] [target]` |\n\n## Footnotes\n\n#### Quotes on Windows\n\nYou should use single quotes in your strings if possible for interoperability\nwith Windows.\n\n```ts\nconst { code, stdout, stderr } = await shell.run(\"my-cmd 'a string'\");\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspellcraftai%2Funiversal-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspellcraftai%2Funiversal-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspellcraftai%2Funiversal-shell/lists"}