| @@ -127,8 +127,12 @@ var getShellTask = (command, args, options) => { | |||
| } | |||
| var callshelltask = (args) => { | |||
| console.dir(args) | |||
| return getshelltask(args)() } | |||
| // console.dir(args) | |||
| if( Object.prototype.toString.call(args) === '[object Function]' ) { | |||
| return args; | |||
| } | |||
| return getshelltask(args)() | |||
| } | |||
| var getshelltask = (args) => { | |||
| return args[0] === 'rm' ? getgitbashtask(args) : () => { return nodeShellExec.apply(null, args) } } | |||
| @@ -694,7 +698,7 @@ var op = { | |||
| dirs(perform_git_seturl) | |||
| } | |||
| // , 'reset' : ()=>{ | |||
| // PB : TODO -- Cant have 2 resets !! | |||
| // PB : TODO -- Cant have 2 resets !! | There is an npm reset that should be bundled. | |||
| // // Reset the whole installation pertaining to this elxr folder. | |||
| // } | |||
| @@ -710,27 +714,52 @@ var op = { | |||
| // PB : TODO -- We should evaluate a whole list of remotes passed in from args instead of just one. | |||
| var commands = [ | |||
| // git remote -v| while read remote; do "${remote#origin/}" "$remote"; done | |||
| // ['git', ['remote', '-v', '| while read remote; do "${remote#origin/}" "$remote"; done'], utils.assign( { | |||
| ['git', ['remote', '-v'], utils.assign( { | |||
| evaluateResult : function(err, result){ | |||
| // var found = result.messages.find( (r)=> { return r.includes( __args.remotename ) }) | |||
| var remotes = [] | |||
| var found = false; | |||
| console.dir(result.messages) | |||
| console.log(result + '---------------') | |||
| result.messages.forEach( (line)=> { | |||
| console.log(line + '$$$$$$$$$$$$$$$$$$$$') | |||
| var matches = line.match(/(.*)?\s\s([^\(]*)?\s?\(?([^\)]*)\)?/); | |||
| if(matches) { | |||
| var remote = {}; | |||
| remote[matches[1]] = matches[2]; | |||
| if( (!matches[3].trim() || matches[3].trim() === 'fetch') && matches[1].trim() === remotename.trim()) { | |||
| found = true; | |||
| result.url = remote[remotename]; | |||
| } | |||
| } | |||
| }) | |||
| console.dir(remotes) | |||
| return [ | |||
| result.messages.find( (r)=> { return r.includes( __args.remotename ) }) | |||
| found | |||
| , result | |||
| ] | |||
| } | |||
| } , options) ] | |||
| , ['git', ['ls-remote', __args.url], utils.assign( { | |||
| evaluateResult : function(err, result){ | |||
| // fatal: unable to access '${__args.url}/': Failed to connect to git.bbh port 80 after 21025 ms: Timed out | |||
| // `fatal: repository '${__args.url}/' not found` | |||
| var hasfailed = /^fatal: .*/.test(result.messages.join(' ')) | |||
| return [ | |||
| !hasfailed, result | |||
| ] | |||
| } | |||
| } , options) ] | |||
| , function(prevserialtaskresult) { | |||
| console.log('================================') | |||
| var url = __args || prevserialtaskresult.url; | |||
| console.dir(prevserialtaskresult) | |||
| return getshelltask(['git', ['ls-remote', url], utils.assign( { | |||
| evaluateResult : function(err, result){ | |||
| // fatal: unable to access '${__args.url}/': Failed to connect to git.bbh port 80 after 21025 ms: Timed out | |||
| // `fatal: repository '${__args.url}/' not found` | |||
| var hasfailed = /^fatal: .*/.test(result.messages.join(' ')) | |||
| return [ | |||
| !hasfailed, result | |||
| ] | |||
| } | |||
| } , options) ])() | |||
| } | |||
| ] | |||
| var mapped = commands.map(callshelltask).map( p => p.catch(e => e)) // Handle errors later. | |||
| return Promise.all(mapped).then( allresolved =>{ | |||
| var mapped = commands.map(callshelltask) //.map( p => p.catch(e => e)) // Handle errors later. | |||
| return any(mapped).then( allresolved =>{ | |||
| console.dir(allresolved) | |||
| !allresolved[0][0] && !allresolved[1][0] ? console.log('was not added as a remote and url is currently inaccessible.') | |||
| : allresolved[0][0] && allresolved[1][0] ? console.log('was added as a remote and url is accessible.') | |||