Skip updating ICU types if they are unchanged
This commit is contained in:
parent
beee8414a3
commit
1fcad38967
1 changed files with 16 additions and 0 deletions
|
@ -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 => {
|
||||
|
|
Loading…
Reference in a new issue