samuel пре 3 година
родитељ
комит
86004a0ea6
1 измењених фајлова са 92 додато и 6 уклоњено
  1. 92
    6
      index.js

+ 92
- 6
index.js Прегледај датотеку

@@ -194,6 +194,14 @@ var elevatedRunasRepos = [
, 'chess-server'
]

var exludeMergeRepos = {
'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true
, 'elixir-data' : true
,'cihsr-config-development' : true, 'cihsr-config-test': true, 'cihsr-config-production' : true
, 'cihsr-data' : true
}


var productionRepos = [
'elixir-config-production'
]
@@ -584,6 +592,90 @@ var __runcmd = function(label){

dirs(perform_init_gitea)
}
, 'syncmaster' : (label) => {
// Usage :
// elxr pull -- Defaults to run config
var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env)
console.log('Running exlr pull : ' + path.dirname(__dirname))
// nodeShellExec('cmd', ['/c', 'setup\\utility\\chess.bat', 'pull'], {
// // nodeShellExec('cmd', ['/c', '..\\setup\\utility\\chess.bat', 'pull'], {
// stdio: ['pipe', process.stdout, process.stderr],
// inherit : true,
// shell: true,
// cwd : path.dirname(__dirname),
// env: env
// })

var useGitPull = processedArgs.useGitPull || false;
var getPullCmd = (repo)=>{
// console.log(useGitPull)

var pullCmd = [ gitInstallDir
, ['-c', 'for i in `git remote`; do git pull $i master; done;']
, { cwd : repo, title : 'pull all origins for ' + repo }]
// var pullCmd = ['pullall', [], { cwd : repo }]
if(useGitPull) pullCmd = ['git', ['pull'], {
inherit : true, shell: true,
cwd : repo
// , env: process.env
, runas : processedArgs.runas
, title : `git pull ${repo}`
}]
return pullCmd
}

var performPull = (repo) => {

if(exludeMergeRepos[repo]) return Promise.resolve({ 'skipped' : true })


if(existsSync(repo)) {
console.log('pulling ' + repo)
return nodeShellExec.apply(null, getPullCmd(repo)).catch((e)=>{ console.error(e) })
}
else {
console.log('cloning ' + repo)
// PB : TODO -- detect if a clonable repo exists in currentGitAuthUser
return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', defaultRepoServer + `/${defaultRepoOwner}/` + repo + '.git'],
{
inherit : true, shell: true,
env: process.env
, runas : processedArgs.runas
}).catch((e)=>{ console.error(e) }).then(()=>{

return nodeShellExec('git', ['config', '--replace-all' , 'core.symlinks', true],
{
inherit : true, shell: true,
env: process.env
, cwd : repo
, runas : processedArgs.runas
, title : `git core.symlinks --replace-all true for ${defaultRepoServer + `/${defaultRepoOwner}/` + repo + '.git'}`
})
})
}
}

if(!processedArgs.runas) gitRepos.forEach(performPull)
return isRunningElevated().then(
(isElevated) => {
if(isElevated) {
any(elevatedRunasRepos.map((repo)=>performPull(repo))).then(()=>{
fs.writeFileSync('run.done', 'success')
}).catch(()=>{
fs.writeFileSync('run.done', 'error')
})
}
else throw false;
}
).catch(
() => {
op['runas']()
}
)
}

, 'pull' : (label) => {
// Usage :
// elxr pull -- Defaults to run config
@@ -863,12 +955,6 @@ var __runcmd = function(label){
'test' : 'master',
'production' : 'master'
}
var exludeMergeRepos = {
'elixir-config-development' : true, 'elixir-config-test': true, 'elixir-config-production' : true
, 'elixir-data' : true
,'cihsr-config-development' : true, 'cihsr-config-test': true, 'cihsr-config-production' : true
, 'cihsr-data' : true
}
var excludeCheckouts = Object.assign(exludeMergeRepos)
delete excludeCheckouts[`elixir-config-${runconfig.NODE_ENV}`]
delete excludeCheckouts[`cihsr-config-${runconfig.NODE_ENV}`]

Loading…
Откажи
Сачувај