mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-17 21:23:54 +01:00
b277975656
* Fix the type declaration of `!!raw-loader!` modules. Instead of declaring them to export an object with a single key `default` which is a string, the modules have a default export, which is a string. Note, that this doesn't actually change the generated code, just the types that typescript sees. The code worked before because the only thing done to the values was to coerce the values to a string, which turned into a no-op. * Switch from using `raw-loader` to using a source asset module. `raw-loader` was deprecated in webpack v5.
35 lines
881 B
JavaScript
35 lines
881 B
JavaScript
const fs = require("fs");
|
|
|
|
const files = [];
|
|
const docRoot = "./src/Documentation/doc";
|
|
const processDir = (dir) => {
|
|
console.log(dir);
|
|
for (const file of fs.readdirSync(dir)) {
|
|
const path = `${dir}/${file}`;
|
|
if (fs.lstatSync(`${dir}/${file}`).isDirectory()) {
|
|
processDir(path);
|
|
continue;
|
|
}
|
|
if (path.startsWith(docRoot + "/")) {
|
|
files.push(path.slice(docRoot.length + 1));
|
|
}
|
|
}
|
|
};
|
|
processDir(docRoot);
|
|
|
|
const autogenfile = `// THIS FILE IS AUTOGENERATED
|
|
${files.map((f, i) => `import file${i} from "./doc/${f}?raw";`).join("\n")}
|
|
|
|
import type { Document } from "./root.ts";
|
|
|
|
export const AllPages: Record<string, Document> = {};
|
|
${files.map((f, i) => `AllPages["${f}"] = file${i};`).join("\n")}
|
|
`;
|
|
|
|
fs.writeFile(docRoot + "/../pages.ts", autogenfile, (err) => {
|
|
if (err) {
|
|
console.error(err);
|
|
}
|
|
// file written successfully
|
|
});
|