mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Chore: detail logging of time consumption
This commit is contained in:
@@ -17,32 +17,38 @@ export async function compareAndWriteFile(linesA: string[], filePath: string) {
|
||||
console.log(`Nothing to write to ${filePath}...`);
|
||||
isEqual = false;
|
||||
} else {
|
||||
let index = 0;
|
||||
isEqual = await traceAsync(
|
||||
picocolors.gray(`Comparing ${filePath}`),
|
||||
async () => {
|
||||
let index = 0;
|
||||
|
||||
for await (const lineB of readFileByLine(file)) {
|
||||
const lineA = linesA[index];
|
||||
index++;
|
||||
for await (const lineB of readFileByLine(file)) {
|
||||
const lineA = linesA[index];
|
||||
index++;
|
||||
|
||||
if (lineA == null) {
|
||||
// The file becomes smaller
|
||||
isEqual = false;
|
||||
break;
|
||||
}
|
||||
if (lineA == null) {
|
||||
// The file becomes smaller
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lineA[0] === '#' && lineB[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
if (lineA[0] === '#' && lineB[0] === '#') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lineA !== lineB) {
|
||||
isEqual = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lineA !== lineB) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isEqual && index !== linesALen) {
|
||||
// The file becomes larger
|
||||
isEqual = false;
|
||||
}
|
||||
if (index !== linesALen) {
|
||||
// The file becomes larger
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
picocolors.gray
|
||||
);
|
||||
}
|
||||
|
||||
if (isEqual) {
|
||||
|
||||
Reference in New Issue
Block a user