Skip to content

Commit d459e27

Browse files
committed
fix: catch invalid json args
Relates to #260
1 parent 7272287 commit d459e27

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/core/src/process/lighthouse.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ setMaxListeners(0);
1616
const { routeReport, port, lighthouseOptions: lighthouseOptionsEncoded }
1717
= minimist<{ options: string, cache: boolean, routeReport: string, port: number }>(process.argv.slice(2))
1818

19-
const routeReportJson: UnlighthouseRouteReport = JSON.parse(routeReport)
19+
let routeReportJson: UnlighthouseRouteReport
20+
try {
21+
routeReportJson = JSON.parse(routeReport)
22+
}
23+
catch (e: unknown) {
24+
console.error('Failed to parse Unlighthouse config. Please create an issue with this output.', process.argv.slice(2), e)
25+
return false
26+
}
2027
const lighthouseOptions: Flags = {
2128
...JSON.parse(lighthouseOptionsEncoded),
2229
// always generate html / json reports

0 commit comments

Comments
 (0)