Fix runPrettier

This commit is contained in:
Joseph Garrone 2024-11-16 21:37:14 +01:00
parent 645031543e
commit 2ad36a8137

View File

@ -62,7 +62,19 @@ export async function runPrettier(params: {
try {
const { prettier, config } = await getPrettierAndConfig();
formattedSourceCode = await prettier.format(sourceCode, { ...config, filePath });
const { ignored, inferredParser } = await prettier.getFileInfo(filePath, {
resolveConfig: true
});
if (ignored) {
return sourceCode;
}
formattedSourceCode = await prettier.format(sourceCode, {
...config,
filePath,
parser: inferredParser ?? undefined
});
} catch (error) {
console.log(
chalk.red(