IronCoreLabs / ironhide

Tool to easily encrypt and decrypt files to users and groups. Similar to GPG, but usable at scale.
GNU Affero General Public License v3.0
44 stars 6 forks source link

Fix logging to wrap text to width of console instead of breaking on words #4

Closed ernieturner closed 4 years ago

ernieturner commented 5 years ago

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));
ernieturner commented 4 years ago

Closing this as it hasn't come up as an issue anytime recently and is low priority