-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclone.js
More file actions
46 lines (36 loc) · 925 Bytes
/
clone.js
File metadata and controls
46 lines (36 loc) · 925 Bytes
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
const path = require('path')
const fs = require('fs')
const { exec, execSync, spawn, spawnSync } = require('child_process')
/**
* 分库站点
* @type {string[]}
*/
const sites = require('./sites')
if (!fs.existsSync(path.resolve(__dirname, 'lottery-sites'))) {
fs.mkdirSync(path.resolve(__dirname, 'lottery-sites'))
}
const task = []
sites.forEach(site => {
const execs = [
`cd ${path.resolve(__dirname, 'lottery-sites')}`,
`git clone gogs@10.10.121.251:xiaokangnew/lottery-repo-${site}.git ${site}`
]
task.push(execs)
})
let i = 0
function execTask () {
const execs = task[i]
if (execs) {
console.log('开始克隆')
exec(execs.join(' && '), function (error, stdout, stderr) {
console.log('stdout: ' + stdout)
console.log('stderr: ' + stderr)
if (error !== null) {
console.log('exec error: ' + error)
}
execTask()
})
}
i++
}
execTask()