test.mjs — astro Source File
Architecture documentation for test.mjs, a javascript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 783c19dd_dc8f_7f70_13d3_d14c83e05c68["test.mjs"] dc804f3e_b1ea_df4a_3cc9_40b536be6a5d["node:child_process"] 783c19dd_dc8f_7f70_13d3_d14c83e05c68 --> dc804f3e_b1ea_df4a_3cc9_40b536be6a5d e16a223b_37f3_6b25_1ee1_2b7bcb9d9415["node:fs"] 783c19dd_dc8f_7f70_13d3_d14c83e05c68 --> e16a223b_37f3_6b25_1ee1_2b7bcb9d9415 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] 783c19dd_dc8f_7f70_13d3_d14c83e05c68 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] 783c19dd_dc8f_7f70_13d3_d14c83e05c68 --> d9a92db9_c95e_9165_13ac_24b3d859d946 style 783c19dd_dc8f_7f70_13d3_d14c83e05c68 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { spawn } from 'node:child_process';
import { readdirSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const dummyGrammarDir = resolve(__dirname, './dummy');
const dummyGrammars = readdirSync(dummyGrammarDir).map((file) => join(dummyGrammarDir, file));
const grammarDir = resolve(__dirname, '../../syntaxes');
const grammars = readdirSync(grammarDir)
.filter((file) => file.endsWith('.json'))
.map((file) => join(grammarDir, file));
const allGrammars = [...grammars, ...dummyGrammars];
/**
* @param {Parameters<typeof spawn>} arg
* @returns {Promise<number | null>}
*/
function promisifySpawn(...arg) {
const childProcess = spawn(...arg);
return new Promise((cb) => {
childProcess.on('exit', (code) => {
cb(code);
});
childProcess.on('error', (err) => {
console.error(err);
cb(1);
});
});
}
async function snapShotTest() {
const extraArgs = process.argv.slice(2);
const isWindows = process.platform === 'win32';
const args = [
'vscode-tmgrammar-snap',
'-s',
'source.astro',
'./test/grammar/fixtures/**/*.astro',
...allGrammars.reduce((/** @type string[] */ previous, path) => [...previous, '-g', path], []),
...extraArgs,
].map((arg) => (isWindows && arg.includes(' ') ? `"${arg}"` : arg));
const code = await promisifySpawn(isWindows ? 'pnpm.cmd' : 'pnpm', args, {
stdio: 'inherit',
shell: isWindows,
});
if (code && code > 0) {
process.exit(code);
}
}
snapShotTest();
Domain
Subdomains
Dependencies
- node:child_process
- node:fs
- node:path
- node:url
Source
Frequently Asked Questions
What does test.mjs do?
test.mjs is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain, RoutingSystem subdomain.
What functions are defined in test.mjs?
test.mjs defines 4 function(s): dummyGrammars, grammars, promisifySpawn, snapShotTest.
What does test.mjs depend on?
test.mjs imports 4 module(s): node:child_process, node:fs, node:path, node:url.
Where is test.mjs in the architecture?
test.mjs is located at packages/language-tools/vscode/test/grammar/test.mjs (domain: CoreAstro, subdomain: RoutingSystem, directory: packages/language-tools/vscode/test/grammar).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free