properties-to-ftl/lib/util-fail.js

22 строки
508 B
JavaScript
Исходник Постоянная ссылка Обычный вид История

2022-01-05 15:30:50 +03:00
import chalk from 'chalk'
/**
* Log an error message and exit the process.
*
* @param {string | Error} error
* @returns {never}
*/
export function fail(error) {
let msg = error instanceof Error ? error.message : error.trim()
if (msg.includes('\n')) msg = '\n' + msg
console.error(
chalk.bold.red('\nError:'),
msg.split('\n').join('\n '),
chalk.dim(`
Use --help for available options.
For more information, see: https://github.com/mozilla/properties-to-ftl`)
)
process.exit(1)
}