diff options
| author | 2023-06-02 14:24:16 -0700 | |
|---|---|---|
| committer | 2023-06-02 14:24:16 -0700 | |
| commit | bfd315fc72749ecd98150de110f2a9cc586c7293 (patch) | |
| tree | f31eb78df5d01a683c3022ce04a122d1dbf6e81e /test | |
| parent | 72c2123e07c936d1c279c5f4effb096f24bc1f58 (diff) | |
| download | bun-bfd315fc72749ecd98150de110f2a9cc586c7293.tar.gz bun-bfd315fc72749ecd98150de110f2a9cc586c7293.tar.zst bun-bfd315fc72749ecd98150de110f2a9cc586c7293.zip | |
Support `NO_COLOR` environment variable (#3055)
Diffstat (limited to 'test')
| -rw-r--r-- | test/cli/bun.test.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/cli/bun.test.ts b/test/cli/bun.test.ts new file mode 100644 index 000000000..97ea52ecd --- /dev/null +++ b/test/cli/bun.test.ts @@ -0,0 +1,35 @@ +import { describe, test, expect } from "bun:test"; +import { spawnSync } from "bun"; +import { bunExe } from "harness"; + +describe("bun", () => { + describe("NO_COLOR", () => { + for (const value of ["1", "0", "foo", " "]) { + test(`respects NO_COLOR=${JSON.stringify(value)} to disable color`, () => { + const { stdout } = spawnSync({ + cmd: [bunExe()], + env: { + NO_COLOR: value, + }, + }); + expect(stdout.toString()).not.toMatch(/\u001b\[\d+m/); + }); + } + for (const value of ["", undefined]) { + // TODO: need a way to fake a tty in order to test this, + // and cannot use FORCE_COLOR since that will always override NO_COLOR. + test.todo(`respects NO_COLOR=${JSON.stringify(value)} to enable color`, () => { + const { stdout } = spawnSync({ + cmd: [bunExe()], + env: + value === undefined + ? {} + : { + NO_COLOR: value, + }, + }); + expect(stdout.toString()).toMatch(/\u001b\[\d+m/); + }); + } + }); +}); |
