@@ -57,7 +57,10 @@ const createEmptyCache = (namespace: string): ParsedFmtCacheFile => ({
5757 optionsUseCounts : [ ] ,
5858} ) ;
5959
60- const parseCacheFile = ( content : string ) : ParsedFmtCacheFile | undefined => {
60+ const parseCacheFile = (
61+ content : string ,
62+ expectedNamespace : string ,
63+ ) : ParsedFmtCacheFile | undefined => {
6164 let value : unknown ;
6265 try {
6366 value = JSON . parse ( content ) ;
@@ -73,7 +76,7 @@ const parseCacheFile = (content: string): ParsedFmtCacheFile | undefined => {
7376 const { version, namespace, options, files } = cache ;
7477 if (
7578 version !== fmtCacheVersion ||
76- typeof namespace !== 'string' ||
79+ namespace !== expectedNamespace ||
7780 ! Array . isArray ( options ) ||
7881 ! Array . isArray ( files ) ||
7982 files . length % fileEntryWidth !== 0
@@ -262,14 +265,12 @@ const loadFmtCacheStore = async (filePath: string, namespace: string): Promise<F
262265
263266 try {
264267 const content = await readFile ( filePath , 'utf8' ) ;
265- const parsed = parseCacheFile ( content ) ;
268+ const parsed = parseCacheFile ( content , namespace ) ;
266269 if ( ! parsed ) {
267270 return new FmtCacheStoreImpl ( filePath , emptyCache , undefined , true ) ;
268271 }
269272
270- return parsed . cache . namespace === namespace
271- ? new FmtCacheStoreImpl ( filePath , parsed , content , false )
272- : new FmtCacheStoreImpl ( filePath , emptyCache , undefined , true ) ;
273+ return new FmtCacheStoreImpl ( filePath , parsed , content , false ) ;
273274 } catch ( error ) {
274275 const missing = isFileNotFoundError ( error ) ;
275276 return new FmtCacheStoreImpl ( filePath , emptyCache , undefined , ! missing ) ;
0 commit comments