/**
 * A custom Error that creates a single-lined message to match current styling inside CLI.
 * Uses original stack trace when `originalError` is passed or erase the stack if it's not defined.
 */ export class CLIError extends Error { constructor ( msg , originalError ? ) { super ( inlineString ( msg ) ) ; if ( originalError ) { this . stack = typeof originalError === 'string' ? originalError : originalError . stack || '' . split ( '\n' ) . slice ( 0 , 2 ) . join ( '\n' ) ; } else { delete this . stack ; } } } export const inlineString = ( str ) => str . replace ( /(\s{2,})/gm , ' ' ) . trim ( ) ;