forked from raycast/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstitch-docs.js
29 lines (23 loc) · 926 Bytes
/
stitch-docs.js
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
const fs = require("fs");
const path = require("path");
const { exec } = require("child_process");
const docs = path.join(__dirname, "../generated-docs");
async function main() {
await new Promise((resolve, reject) =>
exec(
`cd "${docs}" && rsync -arv ./utils-reference/.gitbook/assets/* ./.gitbook/assets && rm -rf ./utils-reference/.gitbook`,
(err, stdout, stderr) => {
if (err || stderr) {
reject(err || new Error(stderr));
} else {
resolve(stdout.trim().split("\n")[0].split(" ")[0]);
}
}
)
);
const summary = fs.readFileSync(path.join(docs, "SUMMARY.md"), "utf-8");
const utilsSummary = fs.readFileSync(path.join(docs, "./utils-reference/SUMMARY.md"), "utf-8");
fs.writeFileSync(path.join(docs, "SUMMARY.md"), summary.replace("---", utilsSummary + "\n---"));
fs.unlinkSync(path.join(docs, "./utils-reference/SUMMARY.md"));
}
main();