Workspace patterns are used to match workspaces when running commands such as run-script or list-workspaces, and they are also used in some configuration options.
Negation is supported by starting any pattern with not:. These exclude workspaces from any other patterns provided.
By default, normal strings match a workspace name or alias.
However, if a wildcard is provided, it will only match against workspace names, to prevent ambiguity.
bw run lint my-name-or-alias "my-name-pattern-*"
See below for how you can use wildcards with aliases.
Matching specifiers give you more control and options for how you match workspaces.
Match by the workspace name (from package.json). Accepts wildcards.
bw ls name:my-workspace "name:my-workspace-*"
bw run lint "name:my-workspace-*"Match by the workspace alias. Accepts wildcards.
bw ls "alias:my-alias-*"
bw run lint "alias:my-alias-b"Match by the relative workspace path, with glob syntax supported.
bw ls "path:packages/**/*"
bw run lint "path:packages/**/*"Match workspaces that have the given tag. Tags are defined in a workspace's configuration file.
bw ls "tag:my-tag"
bw run lint "tag:my-tag-pattern-*"You can negate a pattern by prefixing it with not:.
These exclude workspaces from any other patterns provided.
# All workspaces except those with the tag "my-tag"
bw ls "*" "not:tag:my-tag"
These same matching patterns can be used in the API.
import { createFileSystemProject } from "bun-workspaces";
const project = createFileSystemProject();
project.findWorkspacesByPattern(
"my-name-or-alias",
"name:my-workspace-*",
"alias:my-alias-*",
"path:packages/**/*",
"tag:my-tag",
);
project.runScriptAcrossWorkspaces({
workspacePatterns: [
"my-name-or-alias",
"name:my-workspace-*",
"alias:my-alias-*",
"path:packages/**/*",
"tag:my-tag",
],
script: "bun lint",
});