-
Notifications
You must be signed in to change notification settings - Fork 548
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrangler tail tty-awareness and json-respecting (#810)
2 quick fixes: - Check `process.stdout.isTTY` at runtime to determine whether to default to "pretty" or "json" output for tailing. - Only print messages like "Connected to {worker}" if in "pretty" mode (errors still throw strings)
- Loading branch information
Cass Fridkin
committed
Apr 15, 2022
1 parent
7e560e1
commit 0ce47a5
Showing
4 changed files
with
139 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
Make `wrangler tail` TTY-aware, and stop printing non-JSON in JSON mode | ||
|
||
Closes #493 | ||
|
||
2 quick fixes: | ||
|
||
- Check `process.stdout.isTTY` at runtime to determine whether to default to "pretty" or "json" output for tailing. | ||
- Only print messages like "Connected to {worker}" if in "pretty" mode (errors still throw strings) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const ORIGINAL_ISTTY = process.stdout.isTTY; | ||
|
||
/** | ||
* Mock `process.stdout.isTTY` | ||
*/ | ||
export function useMockIsTTY() { | ||
/** | ||
* Explicitly set `process.stdout.isTTY` to a given value | ||
*/ | ||
const setIsTTY = (isTTY: boolean) => { | ||
process.stdout.isTTY = isTTY; | ||
}; | ||
|
||
beforeEach(() => { | ||
process.stdout.isTTY = ORIGINAL_ISTTY; | ||
}); | ||
|
||
afterEach(() => { | ||
process.stdout.isTTY = ORIGINAL_ISTTY; | ||
}); | ||
|
||
return { setIsTTY }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters