build-grammar.mjs — astro Source File
Architecture documentation for build-grammar.mjs, a javascript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 4b5bb71e_3e72_6bf4_51bf_81a3e53f2ebb["build-grammar.mjs"] e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 4b5bb71e_3e72_6bf4_51bf_81a3e53f2ebb --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] 4b5bb71e_3e72_6bf4_51bf_81a3e53f2ebb --> d9a92db9_c95e_9165_13ac_24b3d859d946 38ee36f6_1b8f_5a62_1295_989b44329ca0["js-yaml"] 4b5bb71e_3e72_6bf4_51bf_81a3e53f2ebb --> 38ee36f6_1b8f_5a62_1295_989b44329ca0 80b99928_2154_ad65_1f34_9c854d2c9ec5["colors"] 4b5bb71e_3e72_6bf4_51bf_81a3e53f2ebb --> 80b99928_2154_ad65_1f34_9c854d2c9ec5 style 4b5bb71e_3e72_6bf4_51bf_81a3e53f2ebb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// @ts-check
import fs from 'node:fs';
import { fileURLToPath } from 'node:url';
import yaml from 'js-yaml';
import { dim, green } from 'kleur/colors';
const dt = new Intl.DateTimeFormat('en-us', {
hour: '2-digit',
minute: '2-digit',
});
// Rebuild grammar when any yaml in the syntaxes directory changes
const syntaxesDir = new URL('../syntaxes/', import.meta.url);
const isWatch = process.argv.includes('--watch');
if (isWatch) {
console.info('Watching for changes in the syntaxes directory...');
}
// Absolute paths to the grammars
const grammarFiles = fs
.readdirSync(syntaxesDir)
.filter((file) => file.endsWith('.src.yaml'))
.map((path) => new URL(path, syntaxesDir));
for (const grammarFile of grammarFiles) {
if (isWatch) {
fs.watch(grammarFile, () => {
buildGrammar(grammarFile);
});
} else {
buildGrammar(grammarFile);
}
}
/**
* @param {URL} grammarFile
*/
function buildGrammar(grammarFile) {
const grammar = yaml.load(fs.readFileSync(grammarFile, 'utf8'));
const finalPath = fileURLToPath(grammarFile).replace('.src.yaml', '.json');
fs.writeFileSync(finalPath, JSON.stringify(grammar, null, 2));
const date = dt.format(new Date());
console.info(dim(`[${date}] `) + green(`✔ updated ${finalPath}`));
}
Domain
Subdomains
Functions
Dependencies
- colors
- js-yaml
- node:fs
- node:url
Source
Frequently Asked Questions
What does build-grammar.mjs do?
build-grammar.mjs is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in build-grammar.mjs?
build-grammar.mjs defines 2 function(s): buildGrammar, grammarFiles.
What does build-grammar.mjs depend on?
build-grammar.mjs imports 4 module(s): colors, js-yaml, node:fs, node:url.
Where is build-grammar.mjs in the architecture?
build-grammar.mjs is located at packages/language-tools/vscode/scripts/build-grammar.mjs (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/language-tools/vscode/scripts).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free