* Prints an error message with recommended fixes (in diff form) for a file with * formatting errors. * * @param {string} file * @return {Promise }
(file)
| 61 | * @return {Promise<void>} |
| 62 | */ |
| 63 | async function printErrorWithSuggestedFixes(file) { |
| 64 | logWithoutTimestamp('\n'); |
| 65 | log(`Suggested fixes for ${cyan(file)}:`); |
| 66 | const options = await getOptions(file); |
| 67 | const original = fs.readFileSync(file).toString(); |
| 68 | const fixed = await prettier.format(original, options); |
| 69 | const fixedFile = `${tempDir}/${file}`; |
| 70 | fs.ensureDirSync(path.dirname(fixedFile)); |
| 71 | fs.writeFileSync(fixedFile, fixed); |
| 72 | const diffCmd = `git -c color.ui=always diff -U0 ${file} ${fixedFile} | tail -n +5`; |
| 73 | exec(diffCmd); |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Prints instructions for how to auto-fix errors. |
no test coverage detected