mirror of
https://github.com/SukkaW/Surge.git
synced 2025-12-12 09:10:35 +08:00
Fix: do not use file handle yet
This commit is contained in:
parent
18d1c1b23e
commit
cec811a629
@ -4,7 +4,6 @@ import picocolors from 'picocolors';
|
|||||||
import type { Span } from '../trace';
|
import type { Span } from '../trace';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import fsp from 'fs/promises';
|
|
||||||
import { sort } from './timsort';
|
import { sort } from './timsort';
|
||||||
import { fastStringArrayJoin } from './misc';
|
import { fastStringArrayJoin } from './misc';
|
||||||
import { readFileByLine } from './fetch-text-by-line';
|
import { readFileByLine } from './fetch-text-by-line';
|
||||||
@ -21,11 +20,9 @@ export async function compareAndWriteFile(span: Span, linesA: string[], filePath
|
|||||||
console.log(`Nothing to write to ${filePath}...`);
|
console.log(`Nothing to write to ${filePath}...`);
|
||||||
isEqual = false;
|
isEqual = false;
|
||||||
} else {
|
} else {
|
||||||
const fd = await fsp.open(filePath);
|
|
||||||
|
|
||||||
isEqual = await span.traceChildAsync(`comparing ${filePath}`, async () => {
|
isEqual = await span.traceChildAsync(`comparing ${filePath}`, async () => {
|
||||||
let index = 0;
|
let index = 0;
|
||||||
for await (const lineB of readFileByLine(fd)) {
|
for await (const lineB of readFileByLine(filePath)) {
|
||||||
const lineA = linesA[index] as string | undefined;
|
const lineA = linesA[index] as string | undefined;
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
@ -60,8 +57,6 @@ export async function compareAndWriteFile(span: Span, linesA: string[], filePath
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
await fd.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEqual) {
|
if (isEqual) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user