46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			46 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
|  | #!/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); | ||
|  | } | ||
|  | 
 |