From 5f4a98e3bcf26bfaaf5ee03489e5344008e2c7d5 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Fri, 24 Mar 2023 14:07:45 +0800 Subject: [PATCH] Throw errors when parser can't be found (#14577) --- src/main/parser.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/parser.js b/src/main/parser.js index 6e3a20cba..46447e155 100644 --- a/src/main/parser.js +++ b/src/main/parser.js @@ -18,12 +18,14 @@ function resolveParser({ plugins, parser }) { } } - /* c8 ignore next 5 */ + /* c8 ignore start */ + let message = `Couldn't resolve parser "${parser}".`; if (process.env.PRETTIER_TARGET === "universal") { - throw new ConfigError( - `Couldn't resolve parser "${parser}". Parsers must be explicitly added to the standalone bundle.` - ); + message += " Parsers must be explicitly added to the standalone bundle."; } + + throw new ConfigError(message); + /* c8 ignore stop */ } async function parse(originalText, options) {