Browse Source

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

production
JArun2018 4 years ago
parent
commit
a67ef49e51
1 changed files with 39 additions and 12 deletions
  1. 39
    12
      index.js

+ 39
- 12
index.js View File

if(Promise.resolve(p) === p ) { if(Promise.resolve(p) === p ) {
return p.then((pVal) => { return p.then((pVal) => {




// Falsy values are task failure.
if(!pVal) {
console.warn('Possible failure for result : ' + pVal)
console.warn(a[i-1])
fn ? console.error("Fn : " + fn.toString()) : null;
}

// Truthy values are failures if obj has error=true.
if(pVal && pVal.error) { console.error('Failed : ' + pVal.message + ' ' + pVal) }

if(Promise.resolve(pVal) === pVal) { if(Promise.resolve(pVal) === pVal) {
// Passed in function retured a promise. We still need to wait for it. // Passed in function retured a promise. We still need to wait for it.
pVal.then((pVal)=>{ pVal.then((pVal)=>{


// 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)=>{
return nodeShellExec('git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true })
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
, runas : processedArgs.runas , runas : processedArgs.runas
}).catch((e)=>{ console.error(e) })
, title : `git switch -C -m ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}`
}).catch((e)=>{ console.error(e); return { error : true, message : repo} })
}

var performPullAll = (repo)=>{
if(excludeCheckouts[repo]) return Promise.resolve({ 'skipped' : true })
return nodeShellExec('git', ['pull', '--all'], {
inherit : true, shell: true,
cwd : repo
, runas : processedArgs.runas
, title : `git switch -C -m ${checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV} for ${repo}`
}).catch((e)=>{ console.error(e); return { error : true, message : repo} })
} }


var mergeSources = { var mergeSources = {
var exludeMergeRepos = { var exludeMergeRepos = {
'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true 'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true
} }
var excludeCheckouts = Object.assign(exludeMergeRepos)
delete excludeCheckouts[`elixir-config-${runconfig.NODE_ENV}`]


var mergeSource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV] var mergeSource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV]
var performMerge = (repo)=>{ var performMerge = (repo)=>{
, runas : processedArgs.runas , runas : processedArgs.runas
}).catch((e)=>{ console.error(e) }) }).catch((e)=>{ console.error(e) })
} }
if(runconfig.NODE_ENV === 'development') performMerge = ()=>{ return Promise.resolve(true) }
if(runconfig.NODE_ENV === 'development') performMerge = ()=>{ return Promise.resolve(true) }


any(tasks).then(()=>{ any(tasks).then(()=>{
if(!processedArgs.runas) return op['runas']() if(!processedArgs.runas) return op['runas']()
) )
} }


return any(tasks.concat([
any(gitRepos.map((repo)=>performCheckout(repo))),
any(elevatedRunasRepos.map((repo)=>performCheckout(repo))),
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)})
, () => {
return any(tasks)
.then(
() => 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(
() => 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)})]) )
.then( () => {
// Move test config from dev. // Move test config from dev.
// if(process.env.NODE_ENV === 'test'){ // if(process.env.NODE_ENV === 'test'){
// var devcfgreponame = runconfig.use + '-config' + '-development'; // var devcfgreponame = runconfig.use + '-config' + '-development';
// else{ // else{
return Promise.resolve(true) return Promise.resolve(true)
// } // }
}
])
).then(()=>{
}).then(()=>{
fs.writeFileSync('run.done', 'success') fs.writeFileSync('run.done', 'success')
}).catch(()=>{ }).catch(()=>{
fs.writeFileSync('run.done', 'error') fs.writeFileSync('run.done', 'error')

Loading…
Cancel
Save