| const processedArgs = cliargs(process.argv.slice(2)); | const processedArgs = cliargs(process.argv.slice(2)); | ||||
| console.dir(processedArgs) | console.dir(processedArgs) | ||||
| var path = require('path') | |||||
| var path = require('path'); | |||||
| const { isMaster } = require('cluster'); | |||||
| // Serialize a set of functions that will execute to return a promises one after the other. | // Serialize a set of functions that will execute to return a promises one after the other. | ||||
| // Will stop when any one fails. | // Will stop when any one fails. | ||||
| function any(iterable, continueOnFailure) { | function any(iterable, continueOnFailure) { | ||||
| kill(serverPid) | kill(serverPid) | ||||
| } | } | ||||
| , 'use' : ()=>{ | , 'use' : ()=>{ | ||||
| // use a certain named instance. | |||||
| // Eg : | |||||
| // 1) elxr use elixir | |||||
| // 2) elxr use cihsr | |||||
| // If environment is not specified defaults to development. | |||||
| // 1) NODE=test elxr use elixir | |||||
| var runconfig = { NODE_ENV : process.env.NODE_ENV } | var runconfig = { NODE_ENV : process.env.NODE_ENV } | ||||
| try { runconfig = Object.assign(runconfig, require('../run.js')) } catch(e) { } | try { runconfig = Object.assign(runconfig, require('../run.js')) } catch(e) { } | ||||
| // console.log(process.env.cwd) | // console.log(process.env.cwd) | ||||
| fs.writeFileSync('./run.js', 'module.exports = ' + JSON.stringify(runconfig)) | fs.writeFileSync('./run.js', 'module.exports = ' + JSON.stringify(runconfig)) | ||||
| var checkoutMap = { | |||||
| 'development' : 'master', | |||||
| } | |||||
| // -b fails... | |||||
| var performCheckout = (repo)=>{ | |||||
| return nodeShellExec('git', ['checkout', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], { | |||||
| inherit : true, shell: true, | |||||
| cwd : repo | |||||
| }).catch((e)=>{ console.error(e) }) | |||||
| } | |||||
| any(tasks).then(()=>{ | any(tasks).then(()=>{ | ||||
| if(!processedArgs.runas) return op['runas']() | if(!processedArgs.runas) return op['runas']() | ||||
| ] | ] | ||||
| ) | ) | ||||
| } | } | ||||
| return any(tasks).then(()=>{ | |||||
| return any(tasks.concat([ | |||||
| any(gitRepos.map((repo)=>performCheckout(repo))), | |||||
| any(elevatedRunasRepos.map((repo)=>performCheckout(repo))) | |||||
| ]) | |||||
| ).then(()=>{ | |||||
| fs.writeFileSync('run.done', 'success') | fs.writeFileSync('run.done', 'success') | ||||
| }).catch(()=>{ | }).catch(()=>{ | ||||
| fs.writeFileSync('run.done', 'error') | fs.writeFileSync('run.done', 'error') |