Mon 21 Jul 22:43:21 CEST 2025
This commit is contained in:
parent
2ec897c622
commit
a54a0f9368
45
js/top/run
Normal file
45
js/top/run
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/node
|
||||||
|
global.TOP='/home/sbosse/proj/jam/js';
|
||||||
|
var debug=false;
|
||||||
|
require(TOP+'/top/module')([process.cwd(),TOP]);
|
||||||
|
|
||||||
|
function out(str) {console.log(str);};
|
||||||
|
function dump() {
|
||||||
|
var e = new Error('dummy');
|
||||||
|
var stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '')
|
||||||
|
.replace(/^\s+at\s+/gm, '')
|
||||||
|
.replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
|
||||||
|
.split('\n');
|
||||||
|
out('Stack Trace');
|
||||||
|
out('--------------------------------');
|
||||||
|
for(var i in stack) {
|
||||||
|
if (i>0) {
|
||||||
|
var line = stack[i];
|
||||||
|
if(line.indexOf('Module.',0)>=0) break;
|
||||||
|
out(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out('--------------------------------');
|
||||||
|
};
|
||||||
|
|
||||||
|
if (process.argv[2]) {
|
||||||
|
if (process.argv[2]=='-d') {
|
||||||
|
debug=true;
|
||||||
|
process.argv.shift();
|
||||||
|
}
|
||||||
|
process.argv.shift();
|
||||||
|
var exec=process.argv[1];
|
||||||
|
process.argv.shift();
|
||||||
|
if (debug)
|
||||||
|
Require(exec);
|
||||||
|
else try {
|
||||||
|
Require(exec);
|
||||||
|
} catch (e) {
|
||||||
|
out(e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('usage: run [-d] <javascript main file>');
|
||||||
|
console.log(' -d: Dump a stack trace on uncaught exceptions');
|
||||||
|
console.log(' TOP='+TOP);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user