Просмотр исходного кода

Added push for new and existing repos.

production
Pradeep Bhaskaran 4 лет назад
Родитель
Сommit
5ae7e50597
1 измененных файлов: 65 добавлений и 0 удалений
  1. 65
    0
      index.js

+ 65
- 0
index.js Просмотреть файл

@@ -244,6 +244,69 @@ var __runcmd = function(label){
);
})
}
, 'push' : ()=>{
if(!processedArgs._[1]) { console.error('push all not supported. Specify repo name'); return }
// init remote bare from local
// pushandinitremotebare
// https://www.jeffgeerling.com/blogs/jeff-geerling/push-your-git-repositories
// connect to repo server -- net use 172.16.0.27
// cd 172.16.0.27/repos/
// mkdir repo.git
// cd repo.git
// git init --bare
// cd localrepo
// git remote rename origin githubclone
// git remote add origin //172.16.0.27/repos/repo.git
// git push origin master

var repo = processedArgs._[1];
var defaultRepoServer = '//172.16.0.27/repos'

var sequentialTaskShellCommands = [];
if(!existsSync(`Z:/${repo}.git`)){
sequentialTaskShellCommands = [
// ['net', ['use', 'Z:', defaultRepoServer.replace('/','\\')], {
// inherit : true, shell: true
// , env: process.env
// }]
['pwd', { cwd : 'Z:', inherit : true}]
, ['mkdir', [`${repo}.git`], {
cwd : `Z:`
, inherit : true, shell: true
, env: process.env
}]
, ['pwd', { cwd : `Z:/${repo}.git`, inherit : true}]
, ['git', ['init', '--bare'], { cwd : `Z:/${repo}.git`
, inherit : true, shell: true
, env: process.env
}]
, ['git', ['remote', 'rename', 'origin', 'githubclone'], { cwd : `${repo}`}] // PB ; Todo -- new repositories created locally will not have origin. Handle this failure.
, ['git', ['remote', 'add', 'origin', `${defaultRepoServer}/${repo}.git`], { cwd : `${repo}`}]
]
if(!existsSync(`Z:`)){
sequentialTaskShellCommands.splice(0,0, ['net', ['use', 'Z:', defaultRepoServer.replace(/\//gm,'\\')], {
inherit : true, shell: true
, env: process.env
}])
console.warn('Adding network drive z: for repo server. ' + sequentialTaskShellCommands[0])
// throw 'done'
}
}

sequentialTaskShellCommands.push(['git', ['push', 'origin', 'master'], { cwd : `${repo}`}])
// console.dir(sequentialTaskShellCommands);

var tasks = [];
sequentialTaskShellCommands.forEach(shellcmd => {
// console.log(shellcmd)
tasks.push(()=>{
var p = nodeShellExec.apply(null, shellcmd).catch((e)=>{ console.error(e) })
return p;
})
})
any(tasks);

}
, 'pull' : (label) => {
var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env)
@@ -476,6 +539,8 @@ __runcmd(processedArgs.label || processedArgs._[0] || 'h');
function nodeShellExec() {

var args = Array.from(arguments);
args[2] ? null : args[2] = {}
args[2].title ? null : args[2].title = `${args[0]} ${args[1]}`
const child = spawn(...arguments);

return new Promise(function(resolve, reject){

Загрузка…
Отмена
Сохранить