-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathmake_docs.ts
More file actions
63 lines (51 loc) · 1.51 KB
/
Copy pathmake_docs.ts
File metadata and controls
63 lines (51 loc) · 1.51 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
53
54
55
56
57
58
59
60
61
62
63
import {exec} from 'child_process'
import fs from 'fs'
import path from 'path'
import pjson from '../src/package.json'
const VERSION=pjson.version
console.log(`Building docs for version ${VERSION}`)
const createDirIfNotExists = (dir: fs.PathLike) => {
if (!fs.existsSync(dir)){
fs.mkdirSync(dir)
}
}
function copyFolderSync(from: fs.PathLike, to: fs.PathLike) {
if(fs.existsSync(to)){
const stat = fs.lstatSync(to)
if (stat.isDirectory()){
fs.rmSync(to, { recursive: true })
}
else{
fs.rmSync(to)
}
}
fs.mkdirSync(to);
fs.readdirSync(from).forEach(element => {
if (fs.lstatSync(path.join(<string>from, element)).isFile()) {
if (typeof from === "string") {
if (typeof to === "string") {
fs.copyFileSync(path.join(from, element), path.join(to, element))
}
}
} else {
if (typeof from === "string") {
if (typeof to === "string") {
copyFolderSync(path.join(from, element), path.join(to, element))
}
}
}
});
}
exec('asciidoctor -v', (err,stdout)=>{
if (err){
console.log('Please install asciidoctor')
console.log('https://asciidoctor.org/docs/install-toolchain/')
process.exit(1)
}
});
createDirIfNotExists('../out')
createDirIfNotExists('../out/doc')
createDirIfNotExists('../out/doc/api')
exec(`asciidoctor -D ../out/doc ../doc/index.adoc ../*/**.adoc -a VERSION=${VERSION}`)
exec(`asciidoctor -D ../out/doc/api ../doc/api/*.adoc -a VERSION=${VERSION}`)
copyFolderSync('../doc/public/', '../out/doc/')