...
|
...
|
@@ -101,19 +101,33 @@ class Build { |
|
|
_cloneCode() {
|
|
|
var self = this;
|
|
|
var syncCodeScript;
|
|
|
var update;
|
|
|
|
|
|
|
|
|
if(sh.ls(config.codeDir).indexOf(this.project.name) > -1) {
|
|
|
syncCodeScript = `git pull origin ${this.branch}`;
|
|
|
update = true;
|
|
|
syncCodeScript = 'git submodule update';
|
|
|
} else {
|
|
|
syncCodeScript = `git submodule add ${this.project.gitlab}`;
|
|
|
syncCodeScript = `git submodule add -f ${this.project.gitlab}`;
|
|
|
}
|
|
|
|
|
|
// let clone_script = `git clone -b develop ${this.project.gitlab}`;
|
|
|
this._log(`>>>>>>>>> ${syncCodeScript} >>>>>>>>>>>`);
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
this._state('sync code');
|
|
|
|
|
|
if (update) {
|
|
|
sh.cd(self.codePath);
|
|
|
var pullChild = sh.exec(`git pull origin ${self.branch}`, {
|
|
|
silent: true
|
|
|
});
|
|
|
|
|
|
if (pullChild.code !== 0) {
|
|
|
reject(new Error(`pull code fail`));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 回到上级目录更新
|
|
|
sh.cd(config.codeDir);
|
|
|
|
|
|
let child = sh.exec(syncCodeScript, {
|
...
|
...
|
@@ -129,10 +143,6 @@ class Build { |
|
|
flags: 'a'
|
|
|
}));
|
|
|
|
|
|
// child.stderr.on('data', (data) => {
|
|
|
// self._log(data);
|
|
|
// });
|
|
|
|
|
|
child.on('close', (code) => {
|
|
|
if (code == 0) {
|
|
|
console.log('sync code success');
|
...
|
...
|
|