Browse Source

Added merge

pull/1/head
Pradeep Bhaskaran 4 years ago
parent
commit
2d3c4ff78d
2 changed files with 28 additions and 32 deletions
  1. 27
    31
      index.js
  2. 1
    1
      windowselevate.hta

+ 27
- 31
index.js View File

var path = require('path'); var path = require('path');
const { isMaster } = require('cluster'); 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 unless continueOnFailure is true.
// All tasks in iterables can be functions or promises.
// promises as usual can return other promises or resolve to either truthy or falsy values.
// functions must return a promise
function any(iterable, continueOnFailure) { function any(iterable, continueOnFailure) {
return iterable.reduce( return iterable.reduce(
(p, fn, i ,a) => { (p, fn, i ,a) => {


// console.log('Then --pVal = ' + pVal + ' bContinue = ' + continueOnFailure ); console.log(p); // console.log('Then --pVal = ' + pVal + ' bContinue = ' + continueOnFailure ); console.log(p);
if(!pVal && !continueOnFailure) { if(!pVal && !continueOnFailure) {
console.error("E : pVal :" + pVal);
// i==0 ? null : console.error("E :1 a[i-1] " + a[i-1]);
// a.map((i)=>console.error(i.toString()));
console.error('debugData 3 -------------------');
// console.error(debugData);
console.error('debugData 3 -------------------');
console.error(`E1 : i = ${i} : pVal :` + pVal);
console.error('debugData 2 -------------------');
console.log("Cancelling remaining..."); console.log("Cancelling remaining...");
throw 'Failed in reduce 1 ' throw 'Failed in reduce 1 '
return false;
} }
// console.log('calling fn : '+ fn);
if(!fn && !continueOnFailure) { console.error('Error : No task specified.'); throw false;}
else if(!fn) return false;
return (Promise.resolve(fn) === fn ) ? fn : fn() ; return (Promise.resolve(fn) === fn ) ? fn : fn() ;
}) })
} }
else { else {


// We will stop on null resolved values on any one task unless continueOnFailure is true.
// console.log('Then --pVal = ' + pVal + ' bContinue = ' + continueOnFailure ); console.log(p); // console.log('Then --pVal = ' + pVal + ' bContinue = ' + continueOnFailure ); console.log(p);
if(!pVal && !continueOnFailure) { if(!pVal && !continueOnFailure) {
console.error("E : pVal :" + pVal);
// i==0 ? null : console.error("E :1 a[i-1] " + a[i-1]);
// a.map((i)=>console.error(i.toString()));
console.error('debugData 3 -------------------');
// console.error(debugData);
console.error('debugData 3 -------------------');
console.error(`E2 : i = ${i} : pVal :` + pVal);
console.error('debugData 2 -------------------');
console.log("Cancelling remaining..."); console.log("Cancelling remaining...");
throw 'Failed in reduce 1 '
return false;
throw 'Failed in reduce 2 '
} }
// console.log('calling fn : '+ fn);
if(!fn && !continueOnFailure) { console.error('Error : No task specified.'); throw false;}
else if(!fn) return false;
return (Promise.resolve(fn) === fn ) ? fn : fn() ; return (Promise.resolve(fn) === fn ) ? fn : fn() ;
} }


}).catch((error) => { }).catch((error) => {
console.error("E : " + error);
console.error(`E3 : i = ${i} `);
fn ? console.error("Fn : " + fn.toString()) : null; fn ? console.error("Fn : " + fn.toString()) : null;
// i==0 ? null : console.error("E :2 a[i-1] " + a[i-1]);
// a.map((i)=>console.error(i.toString()));
console.error('debugData 4-------------------------');
// console.error(debugData);
console.error('debugData 4-------------------------');

throw 'Failed in reduce 2 '
return false;
console.error('debugData 3-------------------------');

throw 'Failed in reduce 3 '
}) })
} }
else if(!p) { else if(!p) {


} }
, 'pull' : (label) => { , 'pull' : (label) => {
// Usage :
// elxr pull -- Defaults to run config
var env = Object.assign({}, process.env); // Shallow clone it. var env = Object.assign({}, process.env); // Shallow clone it.
// console.dir(env) // console.dir(env)
console.log('Running exlr pull : ' + path.dirname(__dirname)) console.log('Running exlr pull : ' + path.dirname(__dirname))
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,
cwd : repo cwd : repo
, runas : processedArgs.runas
}).catch((e)=>{ console.error(e) }) }).catch((e)=>{ console.error(e) })
} }


return nodeShellExec('git', ['merge', mergeSource], { return nodeShellExec('git', ['merge', mergeSource], {
inherit : true, shell: true, inherit : true, shell: true,
cwd : repo cwd : repo
, runas : processedArgs.runas
}).catch((e)=>{ console.error(e) }) }).catch((e)=>{ console.error(e) })
} }
if(runconfig.NODE_ENV === 'development') performMerge = ()=>{}
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([ 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))),
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)})
, () => { , () => {
// Move test config from dev. // Move test config from dev.
if(process.env.NODE_ENV === 'test'){ if(process.env.NODE_ENV === 'test'){
}).catch((e)=>{ console.error(e) }) }).catch((e)=>{ console.error(e) })
) )
Promise.all(promises).then(()=> {
return Promise.all(promises).then(()=> {
globSync( '**/*.test.js', {cwd : devcfgdir}).map((filename) => { globSync( '**/*.test.js', {cwd : devcfgdir}).map((filename) => {
console.log('File found : ' + devcfgdir + filename) console.log('File found : ' + devcfgdir + filename)

+ 1
- 1
windowselevate.hta View File

</script> </script>


<script language="javascript"> <script language="javascript">
// alert(NODE_ENV);
//WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no" //WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no"
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine) // alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3); var args = windowselevate.commandLine.split('"').slice(3);
// alert(args) // alert(args)

Loading…
Cancel
Save