Skip to content

Commit

Permalink
linted help url tool
Browse files Browse the repository at this point in the history
  • Loading branch information
e9gille committed Jul 8, 2019
1 parent 67dc295 commit f3aa691
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions tools/chk-hlp-urls.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
#!/usr/bin/env node
D={modules:{}};require('../src/hlp');let n=0,m=0; //n:total,m:failed
const h=D.hlp,http=require('http'),a=Object.keys(h).map(k=>h[k]).sort(),o={host:'help.dyalog.com',port:80,path:''}
,rec=i=>{if(i>=a.length){console.log(m?'failed:'+m+'/'+n:'ok');return}
n++;o.path=escape(a[i].replace(/^http:\/\/[a-z0-9\.]+\//i,'/').replace(/#.*/,''))
http.get(o,x=>{let c=x.statusCode;console.log((c===200?' ':c)+' '+a[i]);m+=c!==200;rec(i+1)})
.on('error',x=>{console.log(JSON.stringify(x.message)+' '+a[i]);m++;rec(i+1)})}
rec(0)
D = { modules: {} };
require('../src/hlp');
const http = require('http');

D.InitHelp(process.argv[2]);
let n = 0; // n:total
let m = 0; // m:failed
const h = D.hlp;
const a = Object.keys(h).map(k => h[k]).sort();
const o = { host: 'help.dyalog.com', port: 80, path: '' };
const rec = (i) => {
if (i >= a.length) {
console.log(m ? `failed:${m}/${n}` : 'ok');
return;
}
n += 1;
o.path = escape(a[i].replace(/^https:\/\/[a-z0-9.]+\//i, '/').replace(/#.*/, ''));
http.get(o, (x) => {
const c = x.statusCode;
console.log(`${c === 200 ? ' ' : c} ${a[i]}`);
m += c !== 200;
rec(i + 1);
})
.on('error', (x) => {
console.log(`${JSON.stringify(x.message)} ${a[i]}`);
m += 1;
rec(i + 1);
});
};
rec(0);

0 comments on commit f3aa691

Please sign in to comment.