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
Christopher Chedeau 2017-01-10 22:10:00 -08:00
parent b37e8c4b36
commit b8e6fc5cb0
1 changed files with 15 additions and 8 deletions

View File

@ -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 => {