File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ type LoadJsonFileOptions = Required<Pick<Options, 'encoding' | 'tabSize'>>
5959const loadJsonFile = async ( filePath : string , { encoding, tabSize } : LoadJsonFileOptions ) => {
6060 const contents = stripBom ( await fs . promises . readFile ( filePath , encoding ) )
6161 return {
62- json : parseJson ( contents , filePath ) ,
62+ json : parseJson ( contents , filePath ) as JsonRoot ,
6363 indent : tabSize === 'preserve' ? detectIndent ( contents ) . indent : tabSize === 'hard' ? '\t' : tabSize === null ? undefined : ' ' . repeat ( tabSize ) ,
6464 }
6565}
@@ -82,7 +82,7 @@ export const modifyJsonFile: ModifyJsonFileGenericFunction = async (path, modify
8282 if ( typeof modifyFields === 'function' ) {
8383 json = await ( modifyFields as any ) ( json )
8484 } else {
85- if ( typeof json !== 'object' || Array . isArray ( json ) ) throw new TypeError ( `${ path } : Root type is not object. Only callback can be used` )
85+ if ( typeof json !== 'object' || Array . isArray ( json ) || json === null ) throw new TypeError ( `${ path } : Root type is not object. Only callback can be used` )
8686 for ( const parts of Object . entries ( modifyFields ) ) {
8787 // todo fix typescript types
8888 const name = parts [ 0 ] as string
You can’t perform that action at this time.
0 commit comments