|
|
@ -14,6 +14,27 @@ const haveGit = fs.existsSync('./.git'); |
|
|
|
* 2. 添加GIT源 |
|
|
|
* 3. 设置默认源以供一键上传 |
|
|
|
*/ |
|
|
|
function getBranch() { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
exec('git branch', function (error, stdout, stderr) { |
|
|
|
if (error) { |
|
|
|
console.log(error); |
|
|
|
reject(error); |
|
|
|
return; |
|
|
|
} |
|
|
|
let branches = stdout.split('\n').slice(0, stdout.split('\n').length - 1); |
|
|
|
branches = branches.filter(v => { |
|
|
|
if (v.indexOf('*') != -1) { |
|
|
|
return true; |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
}) |
|
|
|
let currentBranch = branches[0].slice(2); |
|
|
|
resolve(currentBranch); |
|
|
|
}); |
|
|
|
}) |
|
|
|
} |
|
|
|
(async () => { |
|
|
|
if (haveGit) { |
|
|
|
exec('git remote', function (error, stdout, stderr) { |
|
|
@ -32,9 +53,10 @@ const haveGit = fs.existsSync('./.git'); |
|
|
|
}]).then(async answers => { |
|
|
|
if (answers.all) { |
|
|
|
// 所有源提交
|
|
|
|
let branch = await getBranch(); |
|
|
|
for (let i = 0; i < origin.length; i++) { |
|
|
|
const o = origin[i]; |
|
|
|
await git_util.all('a', o); |
|
|
|
await git_util.all('a', o, branch); |
|
|
|
} |
|
|
|
} else { |
|
|
|
inquirer.prompt([{ |
|
|
|