Skip to content

Commit 7c9e131

Browse files
committed
Add constant for builtin languages file path
1 parent 130ab2d commit 7c9e131

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

pr-checks/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,13 @@ export const PR_CHECK_EXCLUDED_FILE = path.join(PR_CHECKS_DIR, "excluded.yml");
1111

1212
/** The path to the esbuild metadata file. */
1313
export const BUNDLE_METADATA_FILE = path.join(PR_CHECKS_DIR, "..", "meta.json");
14+
15+
/** The `src` directory. */
16+
const SOURCE_ROOT = path.join(PR_CHECKS_DIR, "..", "src");
17+
18+
/** The path to the built-in languages file. */
19+
export const BUILTIN_LANGUAGES_FILE = path.join(
20+
SOURCE_ROOT,
21+
"languages",
22+
"builtin.json",
23+
);

pr-checks/update-builtin-languages.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import * as path from "node:path";
1717

1818
import * as yaml from "yaml";
1919

20+
import { BUILTIN_LANGUAGES_FILE } from "./config";
21+
2022
const codeqlPath = process.argv[2] || "codeql";
2123

2224
// Step 1: Resolve all language extractor directories.
@@ -75,19 +77,11 @@ const aliases: Record<string, string> = Object.fromEntries(
7577
.sort(([a], [b]) => a.localeCompare(b)),
7678
);
7779

78-
// Step 4: Write builtin.json.
79-
const outputPath = path.join(
80-
__dirname,
81-
"..",
82-
"src",
83-
"languages",
84-
"builtin.json",
85-
);
86-
80+
// Step 4: Update the built-in languages file.
8781
const content = `${JSON.stringify({ languages, aliases }, null, 2)}\n`;
88-
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
89-
fs.writeFileSync(outputPath, content);
82+
fs.mkdirSync(path.dirname(BUILTIN_LANGUAGES_FILE), { recursive: true });
83+
fs.writeFileSync(BUILTIN_LANGUAGES_FILE, content);
9084

91-
console.log(`\nWrote ${outputPath}`);
85+
console.log(`\nWrote ${BUILTIN_LANGUAGES_FILE}`);
9286
console.log(` Languages: ${languages.join(", ")}`);
9387
console.log(` Aliases: ${Object.keys(aliases).join(", ")}`);

0 commit comments

Comments
 (0)