Skip updating ICU types if they are unchanged

This commit is contained in:
Fedor Indutny 2024-03-14 10:14:58 -07:00 committed by GitHub
parent beee8414a3
commit 1fcad38967
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
import fs from 'fs/promises';
import { createHash } from 'crypto';
import path from 'path';
import ts from 'typescript';
import prettier from 'prettier';
@ -236,12 +237,27 @@ async function main() {
'build',
'ICUMessageParams.d.ts'
);
let oldHash: string | undefined;
try {
oldHash = createHash('sha512')
.update(await fs.readFile(destinationPath))
.digest('hex');
} catch {
// Ignore errors
}
const prettierConfig = await prettier.resolveConfig(destinationPath);
const output = prettier.format(unformattedOutput, {
...prettierConfig,
filepath: destinationPath,
});
const newHash = createHash('sha512').update(output).digest('hex');
if (oldHash === newHash) {
console.log('ICUMessageParams.d.ts is unchanged');
}
await fs.writeFile(destinationPath, output);
}
main().catch(error => {