Refactor/整理项目对话错误相关代码 #593
@@ -77,14 +77,14 @@ function snapshot(dir) {
|
||||
console.warn(`目录不存在,跳过校验:${dir}`);
|
||||
return new Map();
|
||||
}
|
||||
const entries = fs.readdirSync(absolute, { recursive: true });
|
||||
return new Map(
|
||||
fs
|
||||
.readdirSync(absolute, { withFileTypes: true })
|
||||
.filter((entry) => entry.isFile())
|
||||
.map((entry) => [
|
||||
path.posix.join(dir, entry.name),
|
||||
fs.readFileSync(path.join(absolute, entry.name)),
|
||||
]),
|
||||
entries.flatMap((entry) => {
|
||||
const absoluteFile = path.join(absolute, entry);
|
||||
if (!fs.lstatSync(absoluteFile).isFile()) return [];
|
||||
const name = path.posix.join(dir, entry.split(path.sep).join('/'));
|
||||
return [[name, fs.readFileSync(absoluteFile)]];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user