From 690ca264142a2b5401257a2fa4ddf7028d89f45f Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Sun, 7 Sep 2025 08:06:37 +0000 Subject: [PATCH] Add --stream flag for workspace script execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements a --stream flag for `bun run` that streams logs immediately without buffering or eliding when running scripts across workspace packages. This is similar to pnpm's --stream flag and addresses user feedback about log display in workspace environments. Changes: - Add --stream flag to CLI parameters for both run and auto commands - Implement streaming output in filter_run.zig that bypasses buffering - Add validation to prevent using --stream with --elide-lines - Add comprehensive test coverage for the new flag - Update documentation in filter.md and run.md The flag provides immediate, unbuffered output which is useful for: - Real-time monitoring of long-running processes - CI/CD environments where immediate feedback is important - Debugging scripts that may hang or have timing issues Fixes the issue where workspace script output was being buffered and elided by default, making it difficult to see logs in real-time. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- docs/cli/filter.md | 27 ++++ docs/cli/run.md | 4 + src/cli.zig | 1 + src/cli/Arguments.zig | 6 + src/cli/filter_run.zig | 24 ++- test/cli/run/filter-workspace.test.ts | 217 ++++++++++++++++++++++++++ 6 files changed, 277 insertions(+), 2 deletions(-) diff --git a/docs/cli/filter.md b/docs/cli/filter.md index bd5e41601f..b839db0af7 100644 --- a/docs/cli/filter.md +++ b/docs/cli/filter.md @@ -71,6 +71,33 @@ bun --filter '*' dev Both commands will be run in parallel, and you will see a nice terminal UI showing their respective outputs: ![Terminal Output](https://github.com/oven-sh/bun/assets/48869301/2a103e42-9921-4c33-948f-a1ad6e6bac71) +### Output options + +By default, when running scripts with `--filter` in a terminal, Bun displays a formatted UI that elides long output to keep the display manageable. You can control this behavior with these flags: + +#### `--elide-lines ` + +Controls how many lines of output are shown for each package (default: 10). Set to 0 to show all output: + +```bash +# Show only 5 lines of output per package +bun --filter '*' --elide-lines 5 test + +# Show all output (no eliding) +bun --filter '*' --elide-lines 0 test +``` + +#### `--stream` + +Stream logs immediately without buffering or eliding. This is useful when you want to see real-time output from all packages, similar to pnpm's `--stream` flag: + +```bash +# Stream all output immediately +bun --filter '*' --stream dev +``` + +Note: `--stream` and `--elide-lines` cannot be used together. When `--stream` is enabled, output is written directly to stdout without package name prefixes or formatting. + ### Running scripts in workspaces Filters respect your [workspace configuration](https://bun.com/docs/install/workspaces): If you have a `package.json` file that specifies which packages are part of the workspace, diff --git a/docs/cli/run.md b/docs/cli/run.md index 80a00b2f93..e5731d8376 100644 --- a/docs/cli/run.md +++ b/docs/cli/run.md @@ -164,6 +164,10 @@ bun run --filter 'ba*'