@zinn-dev/cli 0.32.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/presentation/color.ts +12 -2
package/README.md
CHANGED
|
@@ -286,7 +286,7 @@ zinn task create MDR --title "Refine the numbers" --json
|
|
|
286
286
|
- Output is a single JSON document on stdout. Empty lists print `[]`.
|
|
287
287
|
- Errors go to stderr as `{ "error": { "message": "..." } }`, stdout stays empty, and the command exits with code 1.
|
|
288
288
|
|
|
289
|
-
Text output is mainly for _visual_ consumption. Colors appear only when the output goes to a terminal and [`NO_COLOR`](https://no-color.org/) is
|
|
289
|
+
Text output is mainly for _visual_ consumption. Colors appear only when the output goes to a terminal and [`NO_COLOR`](https://no-color.org/) is not set. In the case that [`FORCE_COLOR`](https://force-color.org/) is set, it overrides both. Note that `FORCE_COLOR=0` turns colors off, and any other value turns them on, even when piped. Piped text is plain otherwise, but its layout may change between versions. Scripts should use `--json` to get reliable output.
|
|
290
290
|
|
|
291
291
|
### Confirmations
|
|
292
292
|
|
package/package.json
CHANGED
|
@@ -2,9 +2,19 @@ import { styleText } from "node:util";
|
|
|
2
2
|
|
|
3
3
|
type StyleFormat = Parameters<typeof styleText>[0];
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Bun's styleText emits ANSI even when stdout is piped or NO_COLOR is set, so Zinn decides when to color.
|
|
7
|
+
* FORCE_COLOR (https://force-color.org/) wins over NO_COLOR and the TTY check.
|
|
8
|
+
* Following https://no-color.org/, any NO_COLOR value turns color off.
|
|
9
|
+
*/
|
|
7
10
|
export function isColorEnabled() {
|
|
11
|
+
const forceColor = process.env.FORCE_COLOR ?? "";
|
|
12
|
+
const isForceColorSet = forceColor.length > 0;
|
|
13
|
+
|
|
14
|
+
if (isForceColorSet) {
|
|
15
|
+
return forceColor !== "0";
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
const isNoColorSet = (process.env.NO_COLOR ?? "").length > 0;
|
|
9
19
|
|
|
10
20
|
return process.stdout.isTTY === true && !isNoColorSet;
|