{"id":18396720,"url":"https://github.com/igorskyflyer/npm-simple-exec","last_synced_at":"2025-04-07T04:32:45.087Z","repository":{"id":55865076,"uuid":"216098492","full_name":"igorskyflyer/npm-simple-exec","owner":"igorskyflyer","description":"🕺 Command. Execution. Made. Simple. ▶","archived":false,"fork":false,"pushed_at":"2024-07-30T18:16:38.000Z","size":1109,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-22T13:23:08.113Z","etag":null,"topics":["back-end","bash","batch","biome","command","exec","execute","igorskyflyer","javascript","linux","macos","node","npm","shell","terminal","unix","vitest","windows"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@igor.dvlpr/simple-exec","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/igorskyflyer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":"igor_dvlpr","open_collective":null,"ko_fi":"igorskyflyer","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-10-18T20:01:57.000Z","updated_at":"2024-07-30T18:16:41.000Z","dependencies_parsed_at":"2022-08-15T08:01:08.356Z","dependency_job_id":null,"html_url":"https://github.com/igorskyflyer/npm-simple-exec","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-simple-exec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-simple-exec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-simple-exec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorskyflyer%2Fnpm-simple-exec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igorskyflyer","download_url":"https://codeload.github.com/igorskyflyer/npm-simple-exec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247595080,"owners_count":20963939,"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":["back-end","bash","batch","biome","command","exec","execute","igorskyflyer","javascript","linux","macos","node","npm","shell","terminal","unix","vitest","windows"],"created_at":"2024-11-06T02:14:39.166Z","updated_at":"2025-04-07T04:32:44.796Z","avatar_url":"https://github.com/igorskyflyer.png","language":"TypeScript","funding_links":["https://patreon.com/igor_dvlpr","https://ko-fi.com/igorskyflyer"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/igorskyflyer/npm-simple-exec/raw/main/assets/simple-exec.png\" title=\"SimpleExec - Command. Execution. Made. Simple.\" alt=\"SimpleExec\" width=\"180\" height=\"180\"\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003eSimpleExec\u003c/h1\u003e\n\n\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cem\u003e🕺Command.\u003c/em\u003e \u003cstrong\u003eExecution.\u003c/strong\u003e \u003cem\u003eMade.\u003c/em\u003e \u003cstrong\u003eSimple. ▶\u003c/strong\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cblockquote\u003e\n    \u003cbr\u003e\n    \u003ch4\u003e💖 Support further development\u003c/h4\u003e\n    \u003cspan\u003eI work hard for every project, including this one\n    \u003cbr\u003e\n    and your support means a lot to me!\n    \u003cbr\u003e\n    \u003cbr\u003e\n    Consider buying me a coffee. ☕\n    \u003cbr\u003e\n    \u003cstrong\u003eThank you for supporting my efforts! 🙏😊\u003c/strong\u003e\u003c/span\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://ko-fi.com/igorskyflyer\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/igorskyflyer/igorskyflyer/main/assets/ko-fi.png\" alt=\"Donate to igorskyflyer\" width=\"150\"\u003e\u003c/a\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \u003ca href=\"https://github.com/igorskyflyer\"\u003e\u003cem\u003e@igorskyflyer\u003c/em\u003e\u003c/a\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n    \u003cbr\u003e\n  \u003c/blockquote\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 📃 Table of contents\n\n- [Usage](#-usage)\n- [API](#-api)\n  - [Types](#types)\n    - [ExecResult](#execresult)\n    - [ExecCallback](#execcallback)\n  - [Functions](#functions)\n    - [executeSync()](#executesynccommand-string-execresult)\n    - [executeCallback()](#executecallbackcommand-string-callback-execcallback-void)\n    - [execute()](#executecommand-string-promisestring)\n    - [executeParallel(...commands)](#executeparallelcommands-string-promisestring)\n    - [executeParallel(commands)](#executeparallelcommands-string-promisestring-1)\n- [Examples](#-examples)\n- [Changelog](#-changelog)\n- [License](#-license)\n- [Related](#-related)\n- [Author](#-author)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## 🕵🏼 Usage\n\nInstall it by executing:\n\n```shell\nnpm i '@igor.dvlpr/simple-exec'\n```\n\n\u003cbr\u003e\n\n## 🤹🏼 API\n\nThe API exposes two types:\n\n- `ExecResult`\n- `ExecCallback`\n\n\u003cbr\u003e\n\n### Types\n\n#### `ExecResult`\n\nA simple object structured as:  \n\n```ts\n{ \n  error: string,\n  output: string\n}\n```\n\n\u003cbr\u003e\n\n#### `ExecCallback`\n\nA callback with the method signature of:  \n\n```ts\ntype ExecCallback = (result: ExecResult) =\u003e void\n```\n\n---\n\n### Functions\n\n#### `executeSync(command: string): ExecResult`\n\n*Synchronously executes the specified command.*  \n\n`command` - Command to execute.  \n\n\u003cbr\u003e\n\nWill throw an error if no command is provided.  \nReturns the `ExecResult` object with standard and error outputs.\n\n\u003cbr\u003e\n\n```js\nimport { executeSync } from '@igor.dvlpr/simple-exec'\n\nconst result = executeSync('dir /b')\n\nif (result.error) {\n  console.error(result.error) // log the error\n} else {\n  console.log(result.output) // log the contents of the directory\n}\n```\n\n---\n\n#### `executeCallback(command: string, callback: ExecCallback): void`\n\n*Asynchronously, with a callback executes the specified command.*  \n\n`command` - Command to execute.  \n`callback` - The function to call after the command is executed.\n\n\u003cbr\u003e\n\nWill throw an error if no command is provided.\n\n\u003cbr\u003e\n\n```js\nimport { executeCallback } from '@igor.dvlpr/simple-exec'\n\nexecuteCallback('node --version', (result) =\u003e {\n  if (result.error) {\n    console.error(result.error) // log the error\n  } else {\n    console.log(result.output) // log Node version\n  }\n})\n```\n\n---\n\n#### `execute(command: string): Promise\u003cstring\u003e`\n\n*Asynchronously executes the specified command.*  \n\n`command` - Command to execute.  \n\n\u003cbr\u003e\n\nWill throw an error if no command is provided.  \nReturns the standard output.\n\n\u003cbr\u003e\n\n```js\nimport { execute } from '@igor.dvlpr/simple-exec'\n\ntry {\n  const result: string = await execute('npm --version')\n\n  console.log(result) // log NPM version\n} catch(exp) {\n  console.error(exp) // log the error\n}\n```\n\n---\n\n#### `executeParallel(...commands: string[]): Promise\u003cstring[]\u003e;`\n\n*Asynchronously and in parallel executes the specified commands.*  \n\n`commands` - Commands to execute, rest string parameters, e.g. `executeParallel('command-one', 'command-two', 'command-three')`.  \n\n\u003cbr\u003e\n\nWill throw an error if any of the commands causes an error.  \nReturns the standard output of each command.\n\n\u003cbr\u003e\n\n```js\nimport { executeParallel } from '@igor.dvlpr/simple-exec'\n\ntry {\n  const results: string[] = await executeParallel('npm --version', 'node --version', 'npm pack')\n  console.log(results) // log the results which is a string array\n} catch(exp) {\n  console.error(exp) // log the error\n}\n```\n\n---\n\n#### `executeParallel(commands: string[]): Promise\u003cstring[]\u003e`\n\n*Asynchronously and in parallel executes the specified commands.*  \n\n`commands` - Commands to execute, a string array, e.g. `executeParallel(['command-one', 'command-two', 'command-three'])`.  \n\n\u003cbr\u003e\n\nWill throw an error if any of the commands causes an error.  \nReturns the standard output of each command.\n\n\u003cbr\u003e\n\n```js\nimport { executeParallel } from '@igor.dvlpr/simple-exec'\n\ntry {\n const results: string[] = executeParallel(['npm --version', 'node --version', 'npm pack'])\n  console.log(results) // log the results which is a string array\n} catch(exp) {\n  console.error(exp) // log the error\n}\n```\n\n---\n\n## ✨ Examples\n\n`example.ts`\n```ts\nimport { executeParallel } from '@igor.dvlpr/simple-exec'\n\nconst result: string[] = await executeParallel([\n  'npm --version',\n  'node --version',\n  'npm --version'\n]) // will log ['\u003cnpm version\u003e', '\u003cNode version\u003e', '\u003cnpm version\u003e']\n  // e.g. [ '10.8.2', 'v22.5.1', '10.8.2' ]\n```\n\n---\n\n## 📝 Changelog\n\n📑 The changelog is available here: [CHANGELOG.md](https://github.com/igorskyflyer/npm-simple-exec/blob/main/CHANGELOG.md).\n\n---\n\n## 🪪 License\n\nLicensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-simple-exec/blob/main/LICENSE).\n\n---\n\n## 🧬 Related\n\n[@igor.dvlpr/mp3size](https://www.npmjs.com/package/@igor.dvlpr/mp3size)\n\n\u003e _🧮 Calculates an estimated file size of Mp3 files. 🎶_\n\n\u003cbr\u003e\n\n[@igor.dvlpr/windev](https://www.npmjs.com/package/@igor.dvlpr/windev)\n\n\u003e _🍃 Provides ways of checking whether a path is a legacy Windows device. 💾_\n\n\u003cbr\u003e\n\n[@igor.dvlpr/emojilyzer](https://www.npmjs.com/package/@igor.dvlpr/emojilyzer)\n\n\u003e _💬 Emojifies strings, converting textual representations of emojis to graphical ones. 🖌️_\n\n\u003cbr\u003e\n\n[@igor.dvlpr/astro-post-excerpt](https://www.npmjs.com/package/@igor.dvlpr/astro-post-excerpt)\n\n\u003e _⭐ An Astro component that renders post excerpts for your Astro blog - directly from your Markdown and MDX files. Astro v2+ collections are supported as well! 💎_\n\n\u003cbr\u003e\n\n[@igor.dvlpr/scrollend-polyfill](https://www.npmjs.com/package/@igor.dvlpr/scrollend-polyfill)\n\n\u003e _🛴 A performant and light (\u003c 1.5KB) JavaScript polyfill for the scrollend Event. ⛸️_\n\n---\n\n\u003cbr\u003e\n\n### 👨🏻‍💻 Author\nCreated by **Igor Dimitrijević** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorskyflyer%2Fnpm-simple-exec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figorskyflyer%2Fnpm-simple-exec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorskyflyer%2Fnpm-simple-exec/lists"}