zkochan / packages

Zoltan Kochan's npm packages
MIT License
99 stars 26 forks source link

[render-help] output exceeded `process.stdout.columns` #147

Closed hyrious closed 1 year ago

hyrious commented 3 years ago

Repro:

let renderHelp = require("render-help")
console.log('width =', process.stdout.columns)
console.log(renderHelp({
  usages: ['pnpm add [options]'],
  descriptionLists: [
    {
      title: 'Options',
      list: [
        {
          name: '--filter',
          description: `averylongsentenceaverylongsentenceaverylongsentenceaverylongsentenceaverylo`
        }
      ]
    }
  ]
}))

Prints:

width = 100
Usage: pnpm add [options]

Options:
      --filter             averylongsentenceaverylongsentenceaverylongsentenceaverylongsentenceavery
lo // <- terminal wraps the line, actually no \n

Edit:

https://github.com/zkochan/packages/blob/7eab98947a769d3ccefb188f9c82e434b74236dc/render-help/src/index.ts#L79

Change the - 1 to - 3 should fix this issue.