MCPcopy
hub / github.com/markedjs/marked / build

Function build

docs/build.js:83–115  ·  view source on GitHub ↗
(currentDir, tmpl, testResultsTable)

Source from the content-addressed store, hash-verified

81];
82
83async function build(currentDir, tmpl, testResultsTable) {
84 const files = await readdir(currentDir);
85 for (const file of files) {
86 const filename = join(currentDir, file);
87 if (ignoredFiles.includes(filename)) {
88 continue;
89 }
90 const stats = await stat(filename);
91 const { mode } = stats;
92 if (stats.isDirectory()) {
93 await build(filename, tmpl);
94 } else {
95 let html = await readFile(filename, 'utf8');
96 const parsed = parse(filename);
97 if (parsed.ext === '.md' && isUppercase(parsed.name)) {
98 const mdHtml = markedInstance.parse(
99 html.replace('<!--{{test-results-table}}-->', testResultsTable),
100 );
101 html = tmpl
102 .replace('<!--{{title}}-->', getTitle(parsed.name))
103 .replace('<!--{{content}}-->', mdHtml);
104 parsed.ext = '.html';
105 parsed.name = parsed.name.toLowerCase();
106 delete parsed.base;
107 }
108 parsed.dir = parsed.dir.replace(inputDir, outputDir);
109 const outfile = format(parsed);
110 await mkdir(dirname(outfile), { recursive: true });
111 console.log('Writing file ' + outfile);
112 await writeFile(outfile, html, { mode });
113 }
114 }
115}
116
117init().catch(console.error);

Callers 1

initFunction · 0.85

Calls 4

isUppercaseFunction · 0.85
getTitleFunction · 0.85
parseFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…