|
@@ -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) {
|