-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.js
38 lines (35 loc) · 1.01 KB
/
update.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
const { exec } = require('child_process');
const fs = require('fs-extra');
const clone = async function() {
await fs.emptyDir(__dirname + '/resource');
console.log('清理文件夹成功');
const clone = exec(
'git clone http://172.72.100.37:13530/SoftwareDevelopment/gaoxin-cli-resource.git ./',
{ cwd: __dirname + '/resource' } /* ... */
);
clone.stdout.on('data', data => {
console.log(data.toString());
});
clone.stderr.on('data', data => {
console.log(data.toString());
});
};
const update = async function() {
const pull = exec('git pull', { cwd: __dirname + '/resource' } /* ... */);
pull.stdout.on('data', data => {
console.log(data.toString());
});
pull.stderr.on('data', data => {
console.log(data.toString());
});
};
const init = async function() {
await fs.ensureDir(__dirname + '/resource');
const exists = await fs.pathExists(__dirname + '/resource/.git');
if (exists) {
await update();
} else {
await clone();
}
};
module.exports = { update, init };