Skip to content

Commit 5f106e8

Browse files
committed
set 130 as the columns default if terminal doesn't support querying
1 parent da09ac9 commit 5f106e8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/core/log.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,20 @@ export async function logPandocJson(
470470
return logPandoc(src, "json");
471471
}
472472

473+
const getColumns = () => {
474+
try {
475+
// Catch error in none tty mode: Inappropriate ioctl for device (os error 25)
476+
return Deno.consoleSize().columns ?? 130;
477+
} catch (_error) {
478+
return 130;
479+
}
480+
};
481+
473482
export async function logPandoc(
474483
src: string,
475484
format: string = "markdown",
476485
) {
477-
const cols = Deno.consoleSize().columns;
486+
const cols = getColumns();
478487
const result = await execProcess({
479488
cmd: [
480489
pandocBinaryPath(),

0 commit comments

Comments
 (0)