Skip to content

Commit 3437a3c

Browse files
authored
feat(tui): Set TURBO_IS_TUI environment variable when using TUI. (#8897)
### Description Tools being used inside Turborepo tasks may want to know if they are being ran in our multiplexer, similar to the way other terminal tooling set environment variables that other programs can read (e.g. `ZSH`,`TMUX`, `ALACRITTY_WINDOW_ID`). In this PR, we're exposing a `TURBO_IS_TUI` variable for this purpose. ### Testing Instructions Using the `with-shell-commands` example, I edited one of the `build` scripts to echo the value. With TUI: ``` TURBO_UI devturbo build --force --skip-infer <omitted for brevity> ┌ pkg-b#build > cache bypass, force executing 33b029c222753bd2 │ │ │ > pkg-b@ prebuild /Users/anthonyshew/projects/debugs/with-shell-commands/packages/pkg-b │ > echo "Executing pre-build step..." │ │ Executing pre-build step... │ │ > pkg-b@ build /Users/anthonyshew/projects/debugs/with-shell-commands/packages/pkg-b │ > echo $TURBO_IS_TUI │ │ true └────> ``` Without TUI: ``` TURBO_UI=0 devturbo build --force --skip-infer --filter=pkg-b turbo 2.0.11 • Packages in scope: pkg-b • Running build in 1 packages • Remote caching disabled pkg-b:prebuild: > echo "Executing pre-build step..." pkg-b:prebuild: pkg-b:prebuild: Executing pre-build step... pkg-b:build: cache bypass, force executing 33b029c222753bd2 pkg-b:build: pkg-b:build: pkg-b:build: > pkg-b@ prebuild /Users/anthonyshew/projects/debugs/with-shell-commands/packages/pkg-b pkg-b:build: > echo "Executing pre-build step..." pkg-b:build: pkg-b:build: Executing pre-build step... pkg-b:build: pkg-b:build: > pkg-b@ build /Users/anthonyshew/projects/debugs/with-shell-commands/packages/pkg-b pkg-b:build: > echo $TURBO_IS_TUI pkg-b:build: pkg-b:build: ```
1 parent 5fc75a3 commit 3437a3c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

crates/turborepo-lib/src/task_graph/visitor.rs

+6
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,12 @@ impl ExecContext {
912912
cmd.envs(self.execution_env.iter());
913913
// Always last to make sure it overwrites any user configured env var.
914914
cmd.env("TURBO_HASH", &self.task_hash);
915+
916+
// Allow downstream tools to detect if the task is being ran with TUI
917+
if self.experimental_ui {
918+
cmd.env("TURBO_IS_TUI", "true");
919+
}
920+
915921
// enable task access tracing
916922

917923
// set the trace file env var - frameworks that support this can use it to

docs/repo-docs/reference/system-environment-variables.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ System environment variables are always overridden by flag values provided direc
3939

4040
Turborepo will make the following environment variables available within your tasks while they are executing:
4141

42-
| Variable | Description |
43-
| ------------ | --------------------------------------- |
44-
| `TURBO_HASH` | The hash of the currently running task. |
42+
| Variable | Description |
43+
| -------------- | -------------------------------------------------------------------------------------------- |
44+
| `TURBO_HASH` | The hash of the currently running task. |
45+
| `TURBO_IS_TUI` | When using the [TUI](/repo/docs/reference/configuration#ui), this variable is set to `true`. |

grep

Whitespace-only changes.

0 commit comments

Comments
 (0)