Skip to content

Commit 76714fb

Browse files
committed
fix(vite-plugin): improve error when console returns invalid JSON
1 parent 47e53c2 commit 76714fb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/vite-plugin-tempest/src/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ async function loadConfigurationFromTempestConsole(): Promise<TempestViteConfigu
5252
const { stdout } = await exec(`${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}`)
5353
const json = stdout.match(/\{.*\}/s)
5454

55-
return JSON.parse(json?.[0] as string)
55+
if (!json?.[0]) {
56+
throw new Error('Could not find valid JSON in Tempest console output')
57+
}
58+
59+
return JSON.parse(json[0])
5660
} catch (error) {
5761
console.error(
5862
`[vite-plugin-tempest] Could not load configuration from [${php.value} ${TEMPEST_BIN} ${VITE_CONFIG_COMMAND}].`,

0 commit comments

Comments
 (0)