Skip to content

Commit 56f2a3e

Browse files
committed
fix: 仅在读取失败时初始化
1 parent 19af9dd commit 56f2a3e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/core/src/files.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,16 @@ export function setupPagesJsonFile(path: string) {
7272
fs.readFileSync = new Proxy(fs.readFileSync, {
7373
apply(target, thisArg, argArray) {
7474
if (typeof argArray[0] === 'string' && normalizePath(argArray[0]) === normalizePath(path)) {
75-
checkPagesJsonFile(path).then(() => {
75+
try {
76+
const data = _readFileSync.apply(thisArg, argArray as any)
7677
fs.readFileSync = _readFileSync
77-
})
78+
return data
79+
}
80+
catch {
81+
checkPagesJsonFile(path).then(() => {
82+
fs.readFileSync = _readFileSync
83+
})
84+
}
7885
return EMPTY_PAGES_JSON_CONTENTS
7986
}
8087
return Reflect.apply(target, thisArg, argArray)

0 commit comments

Comments
 (0)