Browse Source

elxr errors and new repo

pull/4/head
Pradeep Bhaskaran 3 years ago
parent
commit
344170c15a
2 changed files with 57 additions and 5 deletions
  1. 54
    5
      index.js
  2. 3
    0
      windowselevate.hta

+ 54
- 5
index.js View File



// Default Config... // Default Config...
var reposervers = [ var reposervers = [
'http://git.bbh'
, '//172.16.0.27/repos'
'http://git.bbh'
, 'https://git.bbh.org.in'
, '//172.16.0.27/repos'
] ]
var defaultRepoServer = reposervers[0]
var defaultRepoServer = reposervers[1]


var currentGitAuthUser ; // nodeShellExec('git', ['config', 'user.email']) ... PB : TODO-- get the current gittea username var currentGitAuthUser ; // nodeShellExec('git', ['config', 'user.email']) ... PB : TODO-- get the current gittea username
var defaultRepoOwner = 'chess'; var defaultRepoOwner = 'chess';
, 'is-git-repo' : (dir)=>{ , 'is-git-repo' : (dir)=>{
return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio : 'ignore'}) return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio : 'ignore'})
} }
, 'set-url' : (remotename, url) => {
var pushable = processedArgs.pushable || false;
remotename = remotename || processedArgs._[1]
url = url || processedArgs._[2]
var serial_perform_git_seturl = (repo)=>{
var options = { cwd : repo }
// console.log(repo)
if(pushable) {
return [
['git', ['remote', 'set-url', remotename, url + '/' + repo], { cwd : repo }]
]
}
else {
console.error('not supported for non-pushable')
}

}
var x = (args)=>{
return ()=>{
// console.log(args)
return nodeShellExec.apply(null, args)
}
// return Promise.resolve(true)
}
var perform_git_seturl = (dir)=>{
op['is-git-repo'](dir).then((code)=>{
any( serial_perform_git_seturl(dir.name).map(x) )
}).catch((e)=>{
// console.log('Failed : ' + dir.name)
})
}

const { readdir } = require("fs").promises

const dirs = async (perform, path) => {
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) {
if (dir.isDirectory()) perform(dir)
}
}

dirs( perform_git_seturl)
}
, 'add' : (remotename, url, branch) => { , 'add' : (remotename, url, branch) => {
var pushable = processedArgs.pushable || false; var pushable = processedArgs.pushable || false;
remotename = remotename || processedArgs._[1] remotename = remotename || processedArgs._[1]
return pullCmd return pullCmd
} }


var errors = [];
var performPull = (repo) => { var performPull = (repo) => {
if(existsSync(repo)) { if(existsSync(repo)) {
console.log('pulling ' + repo) console.log('pulling ' + repo)
return nodeShellExec.apply(null, getPullCmd(repo)).catch((e)=>{ console.error(e) })
return nodeShellExec.apply(null, getPullCmd(repo)).catch((e)=>{
errors.push({ repo , e})
console.error(e) })
} }
else { else {
console.log('cloning ' + repo) console.log('cloning ' + repo)
inherit : true, shell: true, inherit : true, shell: true,
env: process.env env: process.env
, runas : processedArgs.runas , runas : processedArgs.runas
}).catch((e)=>{ console.error(e) }).then(()=>{
}).catch((e)=>{
errors.push({ repo , e})
console.error(e)
}).then(()=>{


return nodeShellExec('git', ['config', '--replace-all' , 'core.symlinks', true], return nodeShellExec('git', ['config', '--replace-all' , 'core.symlinks', true],
{ {

+ 3
- 0
windowselevate.hta View File

var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' '); var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
// alert(cargs) // alert(cargs)
var shell = new ActiveXObject('shell.application'); var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
shell.ShellExecute('node', cargs, '', 'runas', 1); shell.ShellExecute('node', cargs, '', 'runas', 1);
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1);
var fso = new ActiveXObject('Scripting.FileSystemObject'); var fso = new ActiveXObject('Scripting.FileSystemObject');
window.onload = function() { window.onload = function() {

Loading…
Cancel
Save