workspaces
Command Description
This command enables rudimentary functionality similar to yarn -workspaces .... It is used to execute scripts on specified “workspaces” (folders under the /projects & /modules directories).
In the root package.json there is a script declared called ws (workspaces for short). This aliases bun run scripts/workspaces.ts to bun ws. This script accepts a few parameters workspace, script, an help.
This cli command respects passthrough parameters delimeted by -- (double hyphen). Anything following the space after -- will be passed to the underlying script called.
| Input Name | Shorthand | Type | Description |
|---|---|---|---|
| workspace | w | string | Name of a workspace under the package.json’s defined workspaces. Can be a workspace specific package.json script or a script in the workspace’s scripts/ directory. |
Example Usage
Running a single workspace
bun ws --workspace foo --script buildRunning a command against multiple workspaces
bun ws -w foo -w bar -s buildRunning a command with passthrough parameters. Here the --mode param is propagated to the build command defined in the specified workspaces. This script will check the workspaces’s scripts directory first. Then the workspaces package.json scripts. If nothing is found that matches the script name it will fail.
bun ws -w foo -w bar -s build -- --mode productionManually call the script
bun run scripts/workspaces.ts -w foo -w bar -s build