mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 17:20:35 +08:00
Fix: handle empty file compare and write properly
This commit is contained in:
parent
a02038704f
commit
d29ce74d52
@ -10,7 +10,7 @@ const { readFileByLine } = require('./fetch-remote-text-by-line');
|
|||||||
async function compareAndWriteFile(linesA, filePath) {
|
async function compareAndWriteFile(linesA, filePath) {
|
||||||
await fse.ensureFile(filePath);
|
await fse.ensureFile(filePath);
|
||||||
|
|
||||||
let isEqual = true;
|
let isEqual = false;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
|
||||||
for await (const lineB of readFileByLine(filePath)) {
|
for await (const lineB of readFileByLine(filePath)) {
|
||||||
@ -23,6 +23,8 @@ async function compareAndWriteFile(linesA, filePath) {
|
|||||||
if (lineA !== lineB) {
|
if (lineA !== lineB) {
|
||||||
isEqual = false;
|
isEqual = false;
|
||||||
break;
|
break;
|
||||||
|
} else {
|
||||||
|
isEqual = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user