CLI Usage

Note: Examples use bw instead of bunx bun-workspaces, which works assuming you have either ran alias bw="bunx bun-workspaces" or placed it in your shell configuration file.

Global Options

Config File

--configFile | -c

Use this option to point to a config file. Otherwise, ./bw.json is used by default.

Examples:
$ bw --configFile=/path/to/your/config.json list-workspaces
$ bw -c /path/to/your/config.json list-workspaces

Working Directory

--cwd | -d

Default: .

Get the project root from a specific directory. This should be where the root package.json of your project is located.

Examples:
$ bw --cwd=/path/to/your/project list-workspaces
$ bw -d /path/to/your/project list-workspaces

Log Level

--logLevel | -l

Values: debuginfowarnerrorsilent

Default: info

Set the logging level. Script output of workspaces is always preserved, except when log level is set to "silent".

Examples:
$ bw --logLevel=silent list-workspaces
$ bw -l error list-workspaces

Commands

List Scripts

list-scripts

List all scripts available with their workspaces

Options:

--name-only Only show script names

--json Output as JSON

--pretty Pretty print JSON

Examples:
$ # Default output. Shows metadata about scripts found in all workspaces
$ bw list-scripts
$
$ # Output only the list of script names
$ bw list-scripts --name-only
$
$ # Output as JSON
$ bw list-scripts --json
$
$ # Output as formatted JSON
$ bw list-scripts --json --pretty

List Workspaces

list-workspaces [pattern]

Aliases: lslist

List all workspaces found in the project. This uses the "workspaces" field in your root package.json file.

Options:

--name-only Only show workspace names

--json Output as JSON

--pretty Pretty print JSON

Examples:
$ # Default output. Shows metadata about workspaces found in all workspaces
$ bw list-workspaces
$
$ # Output only the list of workspace names
$ bw list-workspaces --name-only
$
$ # Output as JSON
$ bw list-workspaces --json
$
$ # Output as formatted JSON
$ bw list-workspaces --json --pretty

Workspace Info

workspace-info <workspace>

Aliases: info

Show metadata about a workspace

Options:

--json Output as JSON

--pretty Pretty print JSON

Examples:
$ # Default output. Shows metadata about a workspace
$ bw workspace-info my-workspace
$
$ # Output as JSON
$ bw workspace-info --json
$
$ # Output as formatted JSON
$ bw workspace-info --json --pretty

Script Info

script-info <script>

Show metadata about a script

Options:

--workspaces-only Only show script's workspace names

--json Output as JSON

--pretty Pretty print JSON

Examples:
$ # Default output. Shows metadata about a script
$ bw script-info my-script
$
$ # Output only the list of workspaces that have the script
$ bw script-info my-script --workspaces-only
$
$ # Output as JSON
$ bw script-info --json
$
$ # Output as formatted JSON
$ bw script-info --json --pretty

Run Script

run <script> [workspaces...]

Run a script in all workspaces that have it in their "scripts" field in their respective package.json.

Options:

--parallel Run the scripts in parallel

--args <args> Args to append to the script command

--noPrefix Do not prefix the workspace name to the script output

Examples:
$ # Run a script for all workspaces that have it in their `scripts` field
$ bw run my-script
$
$ # Run a scripts in parallel (logs are prefixed by default)
$ bw run my-script --parallel
$
$ # By default, a prefix is added to the script output with the workspace name
$ bw run my-script --noPrefix
$
$ # Run a script for a specific workspace
$ bw run my-script my-workspace
$
$ # Run a script for multiple workspaces
$ bw run my-script my-workspace-a my-workspace-b
$
$ # Run a script for workspaces using wildcard (does not take into account workspace aliases)
$ bw run my-script my-workspace-*"
$
$ # Append args to each script call
$ bw run my-script --args="--my args"
$
$ # Use the workspace name in args
$ bw run my-script --args="--my --arg=<workspace>"