{"id":28364600,"url":"https://github.com/toolbuilder/rollup-plugin-commands","last_synced_at":"2026-04-22T21:34:45.741Z","repository":{"id":57167198,"uuid":"275474196","full_name":"toolbuilder/rollup-plugin-commands","owner":"toolbuilder","description":"Configurable Rollup plugin to run async functions in sequence. Includes shell function for convenience.","archived":false,"fork":false,"pushed_at":"2024-11-07T15:07:54.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-04T23:37:14.332Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/toolbuilder.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2020-06-28T00:05:56.000Z","updated_at":"2024-11-07T15:08:04.000Z","dependencies_parsed_at":"2024-11-07T16:20:11.527Z","dependency_job_id":"1883c1f4-71ec-408e-8890-4393fc291d20","html_url":"https://github.com/toolbuilder/rollup-plugin-commands","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/toolbuilder/rollup-plugin-commands","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-commands","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-commands/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-commands/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-commands/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toolbuilder","download_url":"https://codeload.github.com/toolbuilder/rollup-plugin-commands/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toolbuilder%2Frollup-plugin-commands/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261063211,"owners_count":23104560,"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-05-28T21:08:18.032Z","updated_at":"2026-04-22T21:34:45.668Z","avatar_url":"https://github.com/toolbuilder.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Rollup Plugin Commands\n\nConfigurable [Rollup](https://rollupjs.org/guide/) plugin to run async functions in sequence. Also provides a shell command for convenience.\n\nFeatures:\n\n* Runs one or more commands in sequence, waiting for each to finish\n* Run commands when Rollup calls `generateBundle` or `writeBundle`, as specified by options\n* Each command is passed the parameters `outputOptions` and `bundle` that are passed to the plugin\n* Run commands only once, or each time Rollup calls `generateBundle` or `writeBundle`\n* Run async or synchronous functions\n* Run shell commands with parameters in a single string (i.e. 'npm test'), courtesy [execa](https://github.com/sindresorhus/execa) and [cross-spawn](https://github.com/moxystudio/node-cross-spawn).\n\n## Installation\n\nUsing npm:\n\n```bash\nnpm install --save-dev @toolbuilder/rollup-plugin-commands\n```\n\n## Use\n\nIf you want just the plugin, but not the `shellCommand`, import like this:\n\n```javascript\nimport runCommands from '@toolbuilder/rollup-plugin-commands'\n```\n\nIf you want the `shellCommand`, import like this:\n\n```javascript\nimport runCommands, { shellCommand } from '@toolbuilder/rollup-plugin-commands'\n```\n\nAlternately, import like this if you don't like the syntax above:\n\n```javascript\nimport { runCommands, shellCommand } from '@toolbuilder/rollup-plugin-commands'\n```\n\n## Example\n\nThe Rollup config [rollup.test.config.js]('./rollup.test.config.js') tests the pack file for this package. It uses `@toolbuilder/rollup-plugin-commands` to install dependencies and run the tests in a temporary directory.\n\n## API\n\n### shellCommand\n\nThis function creates an async function that executes a shell command with option `{ stdio: 'inherit' }` so that the output is part of the Rollup stream. It uses `execa` to execute the script. If the script does not return `0`, an exception is thrown.\n\nTypical use of `shellCommand` looks like this:\n\n```javascript\nimport runCommands, { shellCommand } from '@toolbuilder/rollup-plugin-commands'\n\nexport default [{\n  /* other configuration here */\n  plugins: [\n    runCommands({\n      commands: [\n        shellCommand(`npm pack`) // runs when 'writeBundle' is called\n      ]\n    })\n  ]\n}]\n```\n\n### RunCommands\n\nThe plugin does nothing without options. The plugin exposes two methods for Rollup to call: `writeBundle` and `generateBundle`. At the appropriate point in Rollup's workflow, these methods will be called with two parameters: `outputOptions` and `bundle`. Depending on your Rollup configuration, these methods may be called more than once. You can control how this plugin behaves with options.\n\nOption parameters are as follows:\n\n#### commands\n\n* Type: `[Function|AsyncFunction]`\n* Default: `[]`\n\nThe `commands` option specifies the commands you want to run. They are run in the sequence provided, and each function must finish before the next function is called. Each function is called with the `outputOptions` and `bundle` parameters passed to the plugin by Rollup. If a function throws, the thrown value is passed to Rollup's context function (i.e. `this.error(yourError)`) so that Rollup reports it normally. However, the command is not passed Rollup's context object - you might as well write your own plugin if you want that.\n\nIf you want to run async functions in parallel, just call them from sync functions that do not return the `Promise`.\n\n```javascript\nconst options = {\n  commands: [\n    async (outputOptions, bundle) =\u003e \"do something async\",\n    () =\u003e \"do something sync next\"\n  ]\n}\n```\n\n#### runOn\n\n* Type: `String`\n* Default: `writeBundle`\n\nSet the `runOn` option to `generateBundle` if you want to run the commands when Rollup calls that method. Depending on the option value, the commands will be run either when `writeBundle` is called or when `generateBundle` is called - not both times. If you want to run for both `writeBundle` and `generateBundle`, use two plugin instances.\n\n```javascript\nconst options = {\n  runOn: 'generateBundle' // tells plugin to run commands when Rollup calls generateBundle\n}\n```\n\n#### once\n\n* Type: `Boolean`\n* Default: `true`\n\nSet this option to `false` if you want to run the commands every time the function you selected (either `generateBundle` or `writeBundle`) is called. The rest of your Rollup configuration determines how many times this happens.\n\n```javascript\nconst options = {\n  once: false\n}\n```\n\n## Contributing\n\nContributions are welcome. Please create a pull request or write up an issue. This package uses the [pnpm](https://pnpm.js.org/) package manager. Run `pnpm run check` to run all the unit tests and validation scripts.\n\n```bash\nnpm install -g pnpm\npnpm install\npnpm run check\n```\n\n## Issues\n\nThis project uses Github issues.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolbuilder%2Frollup-plugin-commands","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoolbuilder%2Frollup-plugin-commands","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoolbuilder%2Frollup-plugin-commands/lists"}