Do not crash when parser can't be inferred

This commit is contained in:
Joseph Garrone 2024-12-04 00:04:49 +01:00
parent 5a7dacfcdd
commit 4bbc0241ec

View File

@ -101,7 +101,7 @@ export async function runPrettier(params: {
resolveConfig: true resolveConfig: true
}); });
if (ignored) { if (ignored || inferredParser === null) {
return sourceCode; return sourceCode;
} }
@ -110,7 +110,7 @@ export async function runPrettier(params: {
formattedSourceCode = await prettier.format(sourceCode, { formattedSourceCode = await prettier.format(sourceCode, {
...config, ...config,
filePath, filePath,
parser: inferredParser ?? undefined parser: inferredParser
}); });
} catch (error) { } catch (error) {
console.log( console.log(