joarwilk / flowgen

Generate flowtype definition files from TypeScript
Other
657 stars 87 forks source link

logger: Avoid crashing when filename longer than terminal width #179

Closed gnprice closed 2 years ago

gnprice commented 2 years ago

Without this, if we call logger.error and the source file we're currently acting on has a long name, we attempt to use a negative number of - characters here, and end up crashing with an error like:

RangeError: Invalid count value
    at String.repeat (<anonymous>)
    at Object.error (…/flowgen/lib/logger.js:55:45)
    at …/flowgen/lib/printers/node.js:478:16
    at Object.fn (…/flowgen/lib/env.js:10:12)
    at Object.propertyDeclaration (…/flowgen/lib/printers/declarations.js:46:31)
    at …/flowgen/lib/printers/node.js:551:36
    at fn (…/flowgen/lib/env.js:10:12)
    at Array.map (<anonymous>)
    at parseNameFromNode (…/flowgen/lib/parse/ast.js:41:86)
    at collectNode (…/flowgen/lib/parse/index.js:67:51)
orta commented 2 years ago

Hah, sure, thanks