{"id":15505333,"url":"https://github.com/hasparus/egzek","last_synced_at":"2025-07-27T07:08:08.692Z","repository":{"id":57220992,"uuid":"235684920","full_name":"hasparus/egzek","owner":"hasparus","description":"opinionated lighweight wrapper around child_process.execSync","archived":false,"fork":false,"pushed_at":"2020-03-20T17:49:21.000Z","size":550,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-26T23:51:29.630Z","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/hasparus.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}},"created_at":"2020-01-22T23:02:27.000Z","updated_at":"2022-10-12T10:41:12.000Z","dependencies_parsed_at":"2022-08-29T04:01:41.226Z","dependency_job_id":null,"html_url":"https://github.com/hasparus/egzek","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/hasparus/egzek","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasparus%2Fegzek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasparus%2Fegzek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasparus%2Fegzek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasparus%2Fegzek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hasparus","download_url":"https://codeload.github.com/hasparus/egzek/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hasparus%2Fegzek/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267320257,"owners_count":24068527,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"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":[],"created_at":"2024-10-02T09:22:45.643Z","updated_at":"2025-07-27T07:08:08.659Z","avatar_url":"https://github.com/hasparus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# egzek\n\n[![Build, Test and Release](https://github.com/hasparus/egzek/workflows/Build,%20Test%20and%20Release/badge.svg)](https://github.com/hasparus/egzek/actions?query=workflow%3A%22Build+and+Test%22)\n[![npm](https://img.shields.io/npm/v/egzek.svg)](https://www.npmjs.com/egzek)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Gitmoji](https://img.shields.io/badge/gitmoji-%20😜%20😍-FFDD67.svg?style=flat-square)](https://gitmoji.carloscuesta.me/)\n\n**An opinionated wrapper around child_process.execSync.**\n\nIt runs each line consecutively and prints it for convenience. \n\n---\n\n### Installation\n\n```sh\nyarn add --dev egzek\n```\n\n### Example\n\n```ts\nimport { exec } from \"egzek\";\n\nexec(`\n  echo \"commands are run sequentially\" \u003e ${filepath}\n  cat ${filepath}\n  rm ${filepath}\n`);\n```\n\nOutput:\n\n```\n ➡ echo \"commands are run sequentially\" \u003e /test-1.txt\n\n ➡ cat /test-1.txt\n\"commands are run sequentially\"\n\n ➡ rm /test-1.txt\n```\n\n#### [**Try it on CodeSandbox.**](https://codesandbox.io/s/egzek-cpf16)\n\n### Why?\n\n- Bash is a hell to maintain. Node is a great alternative for utility scripts\n- I wanted something smaller and simpler than [executive](https://www.npmjs.com/package/executive) and [execa](https://www.npmjs.com/package/execa).\n  - **small**\n    - 7.36kB unpacked\n    - 479B gzipped, 428B Brotli.\n    - 831B of uncompressed JavaScript code, 1.2kB of types.\n  - **simple**\n    - one exported function and one exported type\n    - almost the same public API as `child_process.execSync`\n      - common defaults for `stdio` and `encoding` options\n\n### Public API\n\n```ts\nimport { ExecSyncOptions, StdioOptions } from \"child_process\";\nexport interface ExecOptions extends Omit\u003cExecSyncOptions, \"encoding\"\u003e {\n  /**\n   * A directory in which the commands are run.\n   */\n  dir?: string;\n  /**\n   * The encoding used for all stdio inputs and outputs.\n   * @default \"utf-8\"\n   * @see https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options\n   */\n  encoding?: BufferEncoding;\n  /**\n   * Child's stdio configuration.\n   * @default \"inherit\"\n   */\n  stdio?: StdioOptions;\n}\nexport declare namespace ExecOptions {\n  interface Pipe extends ExecOptions {\n    stdio: \"pipe\" | [any, \"pipe\", any?];\n  }\n  interface Inherit extends ExecOptions {\n    stdio?: \"inherit\" | [any, \"inherit\", any?];\n  }\n}\n/**\n * @example\n *  exec(`\n *    echo \"commands are run sequentially\" \u003e ${filepath}\n *    cat ${filepath}\n *  `);\n *\n * @returns array of strings when options.stdio is `pipe`, otherwise undefined\n */\nexport declare function exec(\n  commands: string,\n  options: ExecOptions.Pipe\n): string[];\nexport declare function exec(\n  commands: string,\n  options?: ExecOptions.Inherit\n): undefined;\n```\n\n#### Types from `@types/node`\n\n- [**`BufferEncoding`**](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b08f4588e8f60c2668e39f97b4ba740f5f2b087/types/node/globals.d.ts#L236) _(global)_\n- [**`StdioOptions`**](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b08f4588e8f60c2668e39f97b4ba740f5f2b087/types/node/child_process.d.ts#L99)\n- [**`ExecSyncOptions`**](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/7b08f4588e8f60c2668e39f97b4ba740f5f2b087/types/node/child_process.d.ts#L326)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasparus%2Fegzek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhasparus%2Fegzek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhasparus%2Fegzek/lists"}