-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpull.js
More file actions
executable file
·38 lines (33 loc) · 1.1 KB
/
pull.js
File metadata and controls
executable file
·38 lines (33 loc) · 1.1 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
// Simple script to pull remote Markdown files.
const path = require('path');
const os = require('os');
const fs = require('fs');
const childProcess = require('child_process')
const mikingUrl = 'https://github.com/miking-lang/miking.git'
const mikingDpplUrl = 'https://github.com/miking-lang/miking-dppl.git'
const remoteDocs = [
{url: mikingUrl, remotePath: "README.md", localPath: "miking"},
{url: mikingDpplUrl, remotePath: "README.md", localPath: "miking-dppl"}
]
let cache = new Map()
for (let rd of remoteDocs) {
let dir = cache.get(rd.url)
if (dir === undefined) {
dir = fs.mkdtempSync(`${os.tmpdir()}${path.sep}`)
childProcess.execSync(`git clone --depth 1 ${rd.url} ${dir}`)
cache.set(rd.url, dir)
}
const header = fs.readFileSync(
path.join(
'docs',
path.dirname(rd.localPath),
`_${path.basename(rd.localPath)}-remote.md`
)
)
const body = fs.readFileSync(path.join(dir,rd.remotePath))
fs.writeFileSync(
path.join('docs', `${rd.localPath}-remote.md`),
header + body
)
}
for (const value of cache.values()) fs.rmdirSync(value, {recursive: true})