MCPcopy
hub / github.com/highlightjs/highlight.js / buildNode

Function buildNode

tools/build_node.js:150–205  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

148];
149
150async function buildNode(options) {
151 mkdir("lib/languages");
152 mkdir("scss/base16");
153 mkdir("styles/base16");
154 mkdir("types");
155
156
157 CORE_FILES.forEach(file => {
158 install(`./${file}`, file);
159 });
160 install("./src/core.d.ts", "lib/core.d.ts");
161 install("./src/core.d.ts", "lib/common.d.ts");
162
163 if (options.esm) {
164 mkdir("es/languages");
165 install("./src/core.d.ts", "es/core.d.ts");
166 install("./src/core.d.ts", "es/common.d.ts");
167 }
168
169 log("Writing styles.");
170 // const styles = await fs.readdir("./src/styles/");
171 glob.sync("**", { cwd: "./src/styles" }).forEach((file) => {
172 const stat = fss.statSync(`./src/styles/${file}`);
173 if (stat.isDirectory()) return;
174
175 if (file.endsWith(".css")) {
176 installCleanCSS(`./src/styles/${file}`, `styles/${file}`, { minify: false });
177 installCleanCSS(`./src/styles/${file}`, `styles/${file.replace(".css", ".min.css")}`, { minify: true });
178 installCleanCSS(`./src/styles/${file}`, `scss/${file.replace(".css", ".scss")}`, { minify: false });
179 } else {
180 // images, etc.
181 install(`./src/styles/${file}`, `styles/${file}`);
182 }
183 });
184
185 let languages = await getLanguages();
186 // filter languages for inclusion in the highlight.js bundle
187 languages = filter(languages, options.languages);
188 const common = languages.filter(l => l.categories.includes("common"));
189
190 log("Writing package.json.");
191 await writePackageJSON(buildPackageJSON(options));
192
193 if (options.esm) {
194 await fs.writeFile(`${process.env.BUILD_DIR}/es/package.json`, `{ "type": "module" }`);
195 await buildESMStub("index");
196 await buildESMStub("common");
197 await buildESMUtils();
198 }
199 await buildCJSIndex("index", languages);
200 await buildCJSIndex("common", common);
201 await buildLanguages(languages, options);
202
203 log("Writing highlight.js");
204 await buildNodeHighlightJS(options);
205}
206
207module.exports.build = buildNode;

Callers

nothing calls this directly

Calls 13

mkdirFunction · 0.85
installFunction · 0.85
installCleanCSSFunction · 0.85
getLanguagesFunction · 0.85
filterFunction · 0.85
writePackageJSONFunction · 0.85
buildPackageJSONFunction · 0.85
buildESMStubFunction · 0.85
buildESMUtilsFunction · 0.85
buildCJSIndexFunction · 0.85
buildLanguagesFunction · 0.85
buildNodeHighlightJSFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…