-
Notifications
You must be signed in to change notification settings - Fork 108
/
install-flixel-docs-repo.js
44 lines (37 loc) · 1.1 KB
/
install-flixel-docs-repo.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
38
39
40
41
42
43
44
const shell = require('shelljs')
const { exec } = require('child_process')
const { paths } = require('./install-docs-config.json')
if (!shell.which('git')) {
shell.echo('Sorry, this script requires git')
shell.exit(1)
}
console.log('Installing flixel-docs to the following paths:')
console.log(paths.join('\n'))
const cwd = shell.pwd().stdout
console.log('Current folder: ' + cwd)
for (const path of paths) {
installDocsToDir(cwd + path)
}
async function installDocsToDir (path) {
if (shell.test('-e', path + '/.git')) {
console.log('Updating flixel-docs in ' + path + '...')
shell.cd(path)
exec('git fetch --all', (err, stdout, _) => {
if (err) {
console.error(err)
return
}
exec('git pull', (pullerr, pullstdout, _) => {
if (pullerr) {
console.error(pullerr)
return
}
console.log(pullstdout.toString())
})
shell.cd(cwd)
})
} else {
console.log('Cloning flixel-docs to ' + path + '...')
exec('git clone --depth 1 --no-single-branch https://github.com/haxeflixel/flixel-docs ' + path)
}
}