File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import fs, { promises as fsPromises } from "fs";
22import type http from "http" ;
33import path from "path" ;
44import { DEFAULT_CONFIG } from "../../config" ;
5+ import { logger } from "./logger" ;
56import { isHttpUrl } from "./net" ;
67const { readdir, readFile } = fsPromises ;
78
@@ -44,7 +45,14 @@ export async function findSWAConfigFile(folder: string) {
4445 const filename = path . basename ( file ) as string ;
4546
4647 if ( filename === DEFAULT_CONFIG . swaConfigFilename || filename === DEFAULT_CONFIG . swaConfigFilenameLegacy ) {
47- const config = JSON . parse ( ( await readFile ( file ) ) . toString ( "utf-8" ) ) ;
48+ let config = { } as SWAConfigFile ;
49+ try {
50+ config = JSON . parse ( ( await readFile ( file ) ) . toString ( "utf-8" ) ) ;
51+ } catch ( err ) {
52+ logger . warn ( `` ) ;
53+ logger . warn ( `Error reading ${ filename } configuration:` ) ;
54+ logger . warn ( `${ ( err as any ) . message } in "${ file } "` ) ;
55+ }
4856
4957 // make sure we are using the right SWA config file.
5058 // Note: some JS frameworks (eg. Nuxt, Scully) use routes.json as part of their config. We need to ignore those
You can’t perform that action at this time.
0 commit comments