Do not fatal when formatting throws
When you are formatting an entire codebase and a single file throw, it shouldn't stop the entire process.master
parent
b37e8c4b36
commit
b8e6fc5cb0
|
@ -39,14 +39,21 @@ filenames.forEach(filename => {
|
|||
return;
|
||||
}
|
||||
|
||||
const output = jscodefmt.format(input, {
|
||||
printWidth: argv["print-width"],
|
||||
tabWidth: argv["tab-width"],
|
||||
bracketSpacing: argv["bracket-spacing"],
|
||||
useFlowParser: argv["flow-parser"],
|
||||
singleQuote: argv["single-quote"],
|
||||
trailingComma: argv["trailing-comma"]
|
||||
});
|
||||
let output;
|
||||
try {
|
||||
output = jscodefmt.format(input, {
|
||||
printWidth: argv["print-width"],
|
||||
tabWidth: argv["tab-width"],
|
||||
bracketSpacing: argv["bracket-spacing"],
|
||||
useFlowParser: argv["flow-parser"],
|
||||
singleQuote: argv["single-quote"],
|
||||
trailingComma: argv["trailing-comma"]
|
||||
});
|
||||
} catch (e) {
|
||||
process.exitCode = 2;
|
||||
console.error(e);
|
||||
return;
|
||||
}
|
||||
|
||||
if (write) {
|
||||
fs.writeFile(filename, output, "utf8", err => {
|
||||
|
|
Loading…
Reference in New Issue