|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
else return Promise.resolve(true); |
|
|
else return Promise.resolve(true); |
|
|
}, |
|
|
}, |
|
|
, () => { |
|
|
|
|
|
// Move test config from dev. |
|
|
|
|
|
if(process.env.NODE_ENV === 'test'){ |
|
|
|
|
|
var devcfgreponame = runconfig.use + '-config' + '-development'; |
|
|
|
|
|
var testcfgreponame = runconfig.use + '-config' + '-test'; |
|
|
|
|
|
|
|
|
|
|
|
var testcfgdir = path.dirname(__dirname) + '/' + testcfgreponame + '/' |
|
|
|
|
|
var devcfgdir = path.dirname(__dirname) + '/' + devcfgreponame + '/' //eg (elxr/../elixir-config.development) |
|
|
|
|
|
|
|
|
|
|
|
var promises = []; |
|
|
|
|
|
|
|
|
|
|
|
promises.push( |
|
|
|
|
|
nodeShellExec('git', ['checkout', 'test'], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : testcfgdir |
|
|
|
|
|
// , env: process.env |
|
|
|
|
|
, runas : processedArgs.runas |
|
|
|
|
|
, title : `git checkout ${testcfgreponame}` |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
) |
|
|
|
|
|
promises.push( |
|
|
|
|
|
nodeShellExec('git', ['checkout', 'master'], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : devcfgdir |
|
|
|
|
|
// , env: process.env |
|
|
|
|
|
, runas : processedArgs.runas |
|
|
|
|
|
, title : `git checkout ${devcfgreponame}` |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
Promise.all(promises).then(()=> { |
|
|
|
|
|
globSync( '**/*.test.js', {cwd : devcfgdir}).map((filename) => { |
|
|
|
|
|
|
|
|
|
|
|
console.log('File found : ' + devcfgdir + filename) |
|
|
|
|
|
fs.copyFileSync(devcfgdir + filename, testcfgdir+ filename); |
|
|
|
|
|
|
|
|
|
|
|
nodeShellExec('git', ['checkout', 'test'], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : devcfgdir |
|
|
|
|
|
// , env: process.env |
|
|
|
|
|
, runas : processedArgs.runas |
|
|
|
|
|
, title : `git checkout ${devcfgreponame}` |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
]; |
|
|
]; |
|
|
runconfig.NODE_ENV = process.env.NODE_ENV = process.env.NODE_ENV || runconfig.NODE_ENV || 'development'; |
|
|
runconfig.NODE_ENV = process.env.NODE_ENV = process.env.NODE_ENV || runconfig.NODE_ENV || 'development'; |
|
|
if(processedArgs._[1] && runconfig.use !== processedArgs._[1]) runconfig.use = processedArgs._[1]; |
|
|
if(processedArgs._[1] && runconfig.use !== processedArgs._[1]) runconfig.use = processedArgs._[1]; |
|
|
|
|
|
|
|
|
'development' : 'master', |
|
|
'development' : 'master', |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// -b fails... |
|
|
|
|
|
|
|
|
// 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], { |
|
|
return nodeShellExec('git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], { |
|
|
inherit : true, shell: true, |
|
|
inherit : true, shell: true, |
|
|
|
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var mergeSources = { |
|
|
|
|
|
'development' : null, |
|
|
|
|
|
'test' : 'master', |
|
|
|
|
|
'production' : 'test' |
|
|
|
|
|
} |
|
|
|
|
|
var exludeMergeRepos = { |
|
|
|
|
|
'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var mergeSource = mergeSources[checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV] |
|
|
|
|
|
var performMerge = (repo)=>{ |
|
|
|
|
|
if(exludeMergeRepos[repo]) return Promise.resolve({ 'skipped' : true }) |
|
|
|
|
|
return nodeShellExec('git', ['merge', mergeSource], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : repo |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
} |
|
|
|
|
|
if(runconfig.NODE_ENV === 'development') performMerge = ()=>{} |
|
|
|
|
|
|
|
|
any(tasks).then(()=>{ |
|
|
any(tasks).then(()=>{ |
|
|
if(!processedArgs.runas) return op['runas']() |
|
|
if(!processedArgs.runas) return op['runas']() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return any(tasks.concat([ |
|
|
return any(tasks.concat([ |
|
|
any(gitRepos.map((repo)=>performCheckout(repo))), |
|
|
any(gitRepos.map((repo)=>performCheckout(repo))), |
|
|
any(elevatedRunasRepos.map((repo)=>performCheckout(repo))) |
|
|
|
|
|
|
|
|
any(elevatedRunasRepos.map((repo)=>performCheckout(repo))), |
|
|
|
|
|
any(gitRepos.map((repo)=>performMerge(repo))), |
|
|
|
|
|
any(elevatedRunasRepos.map((repo)=>performMerge(repo))), |
|
|
|
|
|
, () => { |
|
|
|
|
|
// Move test config from dev. |
|
|
|
|
|
if(process.env.NODE_ENV === 'test'){ |
|
|
|
|
|
var devcfgreponame = runconfig.use + '-config' + '-development'; |
|
|
|
|
|
var testcfgreponame = runconfig.use + '-config' + '-test'; |
|
|
|
|
|
|
|
|
|
|
|
var testcfgdir = path.dirname(__dirname) + '/' + testcfgreponame + '/' |
|
|
|
|
|
var devcfgdir = path.dirname(__dirname) + '/' + devcfgreponame + '/' //eg (elxr/../elixir-config.development) |
|
|
|
|
|
|
|
|
|
|
|
var promises = []; |
|
|
|
|
|
|
|
|
|
|
|
promises.push( |
|
|
|
|
|
nodeShellExec('git', ['checkout', 'test'], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : testcfgdir |
|
|
|
|
|
// , env: process.env |
|
|
|
|
|
, runas : processedArgs.runas |
|
|
|
|
|
, title : `git checkout ${testcfgreponame}` |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
) |
|
|
|
|
|
promises.push( |
|
|
|
|
|
nodeShellExec('git', ['checkout', 'master'], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : devcfgdir |
|
|
|
|
|
// , env: process.env |
|
|
|
|
|
, runas : processedArgs.runas |
|
|
|
|
|
, title : `git checkout ${devcfgreponame}` |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
Promise.all(promises).then(()=> { |
|
|
|
|
|
globSync( '**/*.test.js', {cwd : devcfgdir}).map((filename) => { |
|
|
|
|
|
|
|
|
|
|
|
console.log('File found : ' + devcfgdir + filename) |
|
|
|
|
|
fs.copyFileSync(devcfgdir + filename, testcfgdir+ filename); |
|
|
|
|
|
|
|
|
|
|
|
nodeShellExec('git', ['checkout', 'test'], { |
|
|
|
|
|
inherit : true, shell: true, |
|
|
|
|
|
cwd : devcfgdir |
|
|
|
|
|
// , env: process.env |
|
|
|
|
|
, runas : processedArgs.runas |
|
|
|
|
|
, title : `git checkout ${devcfgreponame}` |
|
|
|
|
|
}).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
]) |
|
|
]) |
|
|
).then(()=>{ |
|
|
).then(()=>{ |
|
|
fs.writeFileSync('run.done', 'success') |
|
|
fs.writeFileSync('run.done', 'success') |