mirror of
https://github.com/SukkaW/Surge.git
synced 2026-03-15 07:26:42 +08:00
Chore: update EOL writing
This commit is contained in:
@@ -11,6 +11,10 @@ import { promisify } from 'node:util';
|
||||
export const fileEqual = createCompareSource(fileEqualWithCommentComparator);
|
||||
|
||||
export async function compareAndWriteFile(span: Span, linesA: string[], filePath: string) {
|
||||
if (linesA[linesA.length - 1] !== '') {
|
||||
linesA.push('');
|
||||
}
|
||||
|
||||
const isEqual = await span.traceChildAsync(`compare ${filePath}`, async () => {
|
||||
if (fs.existsSync(filePath)) {
|
||||
return fileEqual(linesA, readFileByLine(filePath));
|
||||
@@ -41,7 +45,9 @@ export async function compareAndWriteFile(span: Span, linesA: string[], filePath
|
||||
// eslint-disable-next-line no-await-in-loop -- stream high water mark
|
||||
if (p) await p;
|
||||
}
|
||||
await promisify(writeStream.end.bind(writeStream))();
|
||||
await new Promise<void>(resolve => {
|
||||
writeStream.end(resolve);
|
||||
});
|
||||
await promisify(writeStream.close.bind(writeStream))();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export function withBannerArray(title: string, description: string[] | readonly
|
||||
|
||||
appendArrayInPlace(result, content);
|
||||
|
||||
result.push('################## EOF ##################', '');
|
||||
result.push('################## EOF ##################');
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user