Files
electron/script/check-patch-diff.mts
Samuel AttardandClaude 8d424eb34d build: run the TypeScript scripts under script/ with plain node (#54168)
ts-node was used as a CLI for a handful of TypeScript scripts under
script/. Those now rely on the type stripping built into Node.js instead:

- script/gen-filenames, check-patch-diff, run-clang-tidy and the release
  helpers (find-github-release, upload-to-github, github-token, types)
  are renamed to .mts and invoked with `node`. They use
  import.meta.dirname and explicit .mts / .js specifiers, and
  tsconfig.script.json moves to nodenext with verbatimModuleSyntax so
  tsc checks them the way Node runs them.
- The documented minimum Node.js for building goes from 22.12 to 22.18,
  the first 22.x release with type stripping on by default.
- script/codesign/gen-trust.ts and its trust.xml template are deleted;
  nothing has invoked them since generate-identity.sh switched to a
  user-scoped keychain in #50058.
- oxfmt, oxlint, lint-staged and .gitattributes learn about .mts.

ts-node itself stays for now because the spec runner still loads specs
through its require hook.

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-21 13:09:47 -07:00

29 lines
892 B
TypeScript

import { spawnSync } from 'node:child_process';
import * as path from 'node:path';
const srcPath = path.resolve(import.meta.dirname, '..', '..', '..');
const patchExportFnPath = path.resolve(import.meta.dirname, 'export_all_patches.py');
const configPath = path.resolve(import.meta.dirname, '..', 'patches', 'config.json');
// Re-export all the patches to check if there were changes.
const proc = spawnSync('python3', [patchExportFnPath, configPath, '--dry-run'], {
cwd: srcPath
});
if (proc.error) {
console.error(proc.error.message);
process.exit(1);
}
if (proc.signal) {
console.error(`Patch export terminated by signal ${proc.signal}`);
process.exit(1);
}
// Fail if patch exporting failed, e.g. dry run found changes.
if (proc.status !== 0) {
console.log(proc.stdout.toString('utf8'));
console.error(proc.stderr.toString('utf8'));
process.exit(proc.status ?? 1);
}