Browse Source

Merge branch 'master' of //172.16.0.27/repos/elxr

production
Pradeep Bhaskaran 4 years ago
parent
commit
fa833b7c87
1 changed files with 68 additions and 0 deletions
  1. 68
    0
      index.js

+ 68
- 0
index.js View File

@@ -252,6 +252,72 @@ 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}`}, (err)=>{
console.log('Ignoring origin rename error : ' + err); return true; //return true to continue.
} ] // 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.slice(0,3)).catch((e)=>{ if(shellcmd[3]) { return shellcmd[3]() } else { console.error(e);} })
return p;
})
})
any(tasks);

}
, 'pull' : (label) => {
var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env)
@@ -489,6 +555,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){

Loading…
Cancel
Save