-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
37 lines (33 loc) · 1.11 KB
/
deploy.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
30
31
32
33
34
35
36
37
(async function () {
const fs = require("fs");
const path = require("path");
const util = require("util");
const mkdocs = path.resolve(".", "venv", "Scripts", "mkdocs.exe");
const config = path.resolve(".", "mkdocs.yml");
const cwd = path.resolve("..", "halak.github.io");
try {
await fs.promises.access(mkdocs, fs.constants.F_OK | fs.constants.R_OK);
await fs.promises.access(config, fs.constants.F_OK | fs.constants.R_OK);
await fs.promises.access(cwd, fs.constants.F_OK | fs.constants.R_OK);
} catch (exception) {
console.error(exception);
return;
}
const args = [
"gh-deploy",
"--config-file", config,
"--remote-branch", "master",
];
const execFile = util.promisify(require("child_process").execFile);
const { stdout, stderr, error } = await execFile(mkdocs, args, { cwd: cwd, shell: false });
if (stdout.length > 0) {
console.log(stdout);
}
if (stderr.length > 0) {
console.error(stderr);
}
if (error) {
throw error;
}
console.log("Deploy complete.");
})();