sass/test/deprecations-check.ts
Jennifer Thakar 87699d79b2
Add deprecations.yaml as a single-source-of-truth (#3872)
Instead of having the list of deprecations repeated in several different
places across all of our repos, the new `spec/deprecations.yaml` file
will be the only place we need to update it, with all other uses
generating code based on it.
2024-05-29 14:23:18 -07:00

23 lines
700 B
TypeScript

import * as crypto from 'crypto';
import * as fs from 'fs';
const yamlFile = 'spec/deprecations.yaml';
const specFile = 'spec/js-api/deprecations.d.ts.md';
const docFile = 'js-api-doc/deprecations.d.ts';
(async () => {
const yamlText = fs.readFileSync(yamlFile, 'utf8');
const specText = fs.readFileSync(specFile, 'utf8');
const docText = fs.readFileSync(docFile, 'utf8');
const checksum = crypto.createHash('sha1').update(yamlText).digest('hex');
if (
!specText.includes(`<!-- Checksum: ${checksum} -->`) ||
!docText.includes(`// Checksum: ${checksum}`)
) {
console.error('Deprecations out-of-sync. Run `npm run sync-deprecations`.');
process.exitCode = 1;
}
})();