|  |  | @@ -34,6 +34,18 @@ function any(iterable, continueOnFailure) { | 
		
	
		
			
			|  |  |  | if(Promise.resolve(p) === p ) { | 
		
	
		
			
			|  |  |  | 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) { | 
		
	
		
			
			|  |  |  | // Passed in function retured a promise. We still need to wait for it. | 
		
	
		
			
			|  |  |  | pVal.then((pVal)=>{ | 
		
	
	
		
			
			|  |  | @@ -577,11 +589,23 @@ var __runcmd = function(label){ | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | // cant use git checkout -b it fails with branch already exists. | 
		
	
		
			
			|  |  |  | 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, | 
		
	
		
			
			|  |  |  | cwd : repo | 
		
	
		
			
			|  |  |  | , 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 = { | 
		
	
	
		
			
			|  |  | @@ -592,6 +616,8 @@ var __runcmd = function(label){ | 
		
	
		
			
			|  |  |  | var exludeMergeRepos = { | 
		
	
		
			
			|  |  |  | '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 performMerge = (repo)=>{ | 
		
	
	
		
			
			|  |  | @@ -602,7 +628,7 @@ var __runcmd = function(label){ | 
		
	
		
			
			|  |  |  | , runas : processedArgs.runas | 
		
	
		
			
			|  |  |  | }).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(()=>{ | 
		
	
		
			
			|  |  |  | if(!processedArgs.runas) return op['runas']() | 
		
	
	
		
			
			|  |  | @@ -631,12 +657,15 @@ var __runcmd = function(label){ | 
		
	
		
			
			|  |  |  | ) | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | 
 | 
		
	
		
			
			|  |  |  | 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. | 
		
	
		
			
			|  |  |  | // if(process.env.NODE_ENV === 'test'){ | 
		
	
		
			
			|  |  |  | // var devcfgreponame =  runconfig.use + '-config' + '-development'; | 
		
	
	
		
			
			|  |  | @@ -687,9 +716,7 @@ var __runcmd = function(label){ | 
		
	
		
			
			|  |  |  | // else{ | 
		
	
		
			
			|  |  |  | return Promise.resolve(true) | 
		
	
		
			
			|  |  |  | // } | 
		
	
		
			
			|  |  |  | } | 
		
	
		
			
			|  |  |  | ]) | 
		
	
		
			
			|  |  |  | ).then(()=>{ | 
		
	
		
			
			|  |  |  | }).then(()=>{ | 
		
	
		
			
			|  |  |  | fs.writeFileSync('run.done', 'success') | 
		
	
		
			
			|  |  |  | }).catch(()=>{ | 
		
	
		
			
			|  |  |  | fs.writeFileSync('run.done', 'error') |