Skip to content

Commit

Permalink
Fix throws in GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Oct 26, 2022
1 parent 64d9889 commit a528122
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ that part; it’s going to *change the world*.
 


# tea/cli 0.9.2
# tea/cli 0.10.0

tea is a universal virtual‑environment manager:

Expand Down
14 changes: 10 additions & 4 deletions src/hooks/useLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ const ansi_escapes_rx = new RegExp([
].join('|'), 'g')

function ln(s: string, prefix: string) {
// remove ansi escapes to get actual length
const n = s.replace(ansi_escapes_rx, '').length + prefix.length + 1
const { columns } = Deno.consoleSize(Deno.stdout.rid)
return Math.ceil(n / columns)
try {
// remove ansi escapes to get actual length
const n = s.replace(ansi_escapes_rx, '').length + prefix.length + 1
const { columns } = Deno.consoleSize(Deno.stdout.rid)
return Math.ceil(n / columns)
} catch {
// consoleSize() throws if not a tty
// eg. in GitHub Actions
return 1
}
}

export default function useLogger(prefix?: string) {
Expand Down

0 comments on commit a528122

Please sign in to comment.