When we log long words to stdout or stderr they can end up getting wrapped at non-ideal locations in the middle of words. This is a bigger issue for when we log text in the login process which dumps out quite a bit of text.
The oclif/help-plugin uses the wrap-ansi plugin along with the following code to wrap at the window width
function termwidth(stream: any): number {
if (!stream.isTTY) {
return 80;
}
const width = stream.getWindowSize()[0];
if (width < 1) {
return 80;
}
if (width < 40) {
return 40;
}
return width;
}
const columns: number | null = parseInt(process.env.COLUMNS!, 10) || (global as any).columns;
console.log(columns || termwidth(process.stdout));
console.log(columns || termwidth(process.stderr));
When we log long words to stdout or stderr they can end up getting wrapped at non-ideal locations in the middle of words. This is a bigger issue for when we log text in the login process which dumps out quite a bit of text.
The
oclif/help-plugin
uses thewrap-ansi
plugin along with the following code to wrap at the window width