|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// cant use git checkout -b it fails with branch already exists. |
|
|
// cant use git checkout -b it fails with branch already exists. |
|
|
var performCheckout = (repo)=>{ |
|
|
|
|
|
|
|
|
var performCheckout = (repo, branch)=>{ |
|
|
|
|
|
if(!branch) return Promise.resolve({ 'skipped' : true }) |
|
|
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true }) |
|
|
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true }) |
|
|
return nodeShellExec('git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], { |
|
|
|
|
|
|
|
|
return nodeShellExec('git', ['checkout', branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], { |
|
|
// return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], { |
|
|
// return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], { |
|
|
// inherit : true, shell: true, |
|
|
// inherit : true, shell: true, |
|
|
cwd : repo |
|
|
cwd : repo |
|
|
// , stdio : ignore // Use when we want to silcence output completely. |
|
|
// , stdio : ignore // Use when we want to silcence output completely. |
|
|
, runas : processedArgs.runas |
|
|
, runas : processedArgs.runas |
|
|
, title : `git checkout ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}` |
|
|
|
|
|
|
|
|
, title : `git checkout ${branch ||checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}` |
|
|
}).catch((e)=>{ console.error(e); return { error : true, message : repo} }) |
|
|
}).catch((e)=>{ console.error(e); return { error : true, message : repo} }) |
|
|
} |
|
|
} |
|
|
if(runconfig.NODE_ENV === 'development') performCheckout = ()=>{ return Promise.resolve(true) } |
|
|
if(runconfig.NODE_ENV === 'development') performCheckout = ()=>{ return Promise.resolve(true) } |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return any(tasks) |
|
|
return any(tasks) |
|
|
.then( |
|
|
|
|
|
|
|
|
//target is the env is we specify in elxr use command. Default is dev |
|
|
|
|
|
.then( //Switch to target branch |
|
|
|
|
|
() => any([ any(gitRepos.map((repo)=>performCheckout(repo, process.env.NODE_ENV || 'development'))) |
|
|
|
|
|
, any(elevatedRunasRepos.map((repo)=>performCheckout(repo, process.env.NODE_ENV || 'development')))]) ) |
|
|
|
|
|
.then( //PULL from target branch |
|
|
() => any([ any(gitRepos.map((repo)=>performPullAll(repo))), any(elevatedRunasRepos.map((repo)=>performPullAll(repo)))]) ) |
|
|
() => any([ any(gitRepos.map((repo)=>performPullAll(repo))), any(elevatedRunasRepos.map((repo)=>performPullAll(repo)))]) ) |
|
|
.then( |
|
|
|
|
|
() => any([ any(gitRepos.map((repo)=>performCheckout(repo))), any(elevatedRunasRepos.map((repo)=>performCheckout(repo)))]) ) |
|
|
|
|
|
.then( |
|
|
|
|
|
|
|
|
.then( //Switch to merge source branch |
|
|
|
|
|
() => any([ any(gitRepos.map((repo)=>performCheckout(repo, mergeSources[process.env.NODE_ENV || 'development'] ))) |
|
|
|
|
|
, any(elevatedRunasRepos.map((repo)=>performCheckout(repo, mergeSources[process.env.NODE_ENV || 'development'])))]) ) |
|
|
|
|
|
.then( //Pull on merge source branch |
|
|
|
|
|
() => any([ any(gitRepos.map((repo)=>performPullAll(repo))), any(elevatedRunasRepos.map((repo)=>performPullAll(repo)))]) ) |
|
|
|
|
|
.then( //Switch to target branch |
|
|
|
|
|
() => any([ any(gitRepos.map((repo)=>performCheckout(repo, process.env.NODE_ENV || 'development'))) |
|
|
|
|
|
, any(elevatedRunasRepos.map((repo)=>performCheckout(repo, process.env.NODE_ENV || 'development')))]) ) |
|
|
|
|
|
.then( //Merge source branch to target branch |
|
|
() => any([ any(gitRepos.map((repo)=>performMerge(repo))).catch(err=>{ console.error('error in performMerge ' + err)}) , |
|
|
() => any([ any(gitRepos.map((repo)=>performMerge(repo))).catch(err=>{ console.error('error in performMerge ' + err)}) , |
|
|
any(elevatedRunasRepos.map((repo)=>performMerge(repo))).catch(err=>{ console.error('error in performMerge ' + err)})]) ) |
|
|
any(elevatedRunasRepos.map((repo)=>performMerge(repo))).catch(err=>{ console.error('error in performMerge ' + err)})]) ) |
|
|
.then( () => { |
|
|
.then( () => { |