-
Notifications
You must be signed in to change notification settings - Fork 1
/
docs.js
32 lines (30 loc) · 935 Bytes
/
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
30
31
32
const yargs = require('yargs');
const { spawn } = require('child_process');
const IMAGE = 'squidfunk/mkdocs-material:5.2.2'
const watch = {
command: 'watch',
describe: 'watch docs',
builder: (yargs) =>
yargs
.number('port')
.default('port', 9090)
.describe('port', 'The port mkdocs should listen on'),
handler: ({port}) => {
const command = `docker run --rm -it -p ${port}:8000 -v ${__dirname}:/docs ${IMAGE}`;
console.log(command);
spawn(command, {
stdio: 'inherit',
shell: true,
});
},
};
const build = {
command: 'build',
describe: 'build docs',
handler: () => {
const command = `docker run --rm -v ${__dirname}:/docs ${IMAGE} build`;
console.log(command);
spawn(command, {stdio: 'inherit', shell: true});
},
};
yargs.command(watch).command(build).demandCommand().argv;