forked from packwiz/packwiz-website
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
52 lines (47 loc) · 1.53 KB
/
Copy pathbuild.js
File metadata and controls
52 lines (47 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const yaml = require("js-yaml");
const fs = require("fs");
const { execSync } = require("child_process");
const { green } = require("kleur/colors");
console.log(green("Installing packwiz..."));
execSync("go install github.com/comp500/packwiz@latest");
console.log(green("Outputting packwiz cli docs..."));
execSync("packwiz utils markdown --dir=docs/reference/commands", {
env: {
...process.env,
PATH: `${process.env.GOPATH}/bin:${process.env.PATH}`,
},
});
console.log(green("Massaging packwiz cli docs into mkdoc compatible form..."));
let mkdocsConfig = yaml.load(fs.readFileSync("mkdocs-base.yml", "utf8"));
Promise.all(
mkdocsConfig.nav.map(async (el) => {
if (el.Reference != null) {
await Promise.all(
el.Reference.map(async (el) => {
if (el.Commands != null) {
el.Commands = [];
const files = await fs.promises.readdir(
"./docs/reference/commands/"
);
for (const file of files) {
let ref = {};
let name = file.slice(0, -3).replace(/_/g, " ");
if (name == "overview") {
name = "Overview";
}
ref[name] = "reference/commands/" + file;
el.Commands.push(ref);
}
}
})
);
}
return el;
})
).then((nav) => {
mkdocsConfig.nav = nav;
fs.writeFileSync("mkdocs.yml", yaml.dump(mkdocsConfig));
console.log(green("Building docs!"));
execSync("mkdocs build");
console.log(green("Successfully built docs!"));
});