views:

53

answers:

1

how do you get the path of the javascript file run through the rhino shell commandline?

eg: java -jar js.jar /path/to/this/file.js

i would like to get /path/to/this/file.js, any ideas?

+1  A: 

I do not think it is possible without some Java. jsdoc solves it by using a class that wraps rhino and inserts said path (though its a bit buggy). You can find its code (and a shell script that runs it is in the trunk): http://code.google.com/p/jsdoc-toolkit/source/browse/trunk/jsdoc-toolkit/java/src/JsRun.java

Eric
thanks very much :o) i shall have a look
Dave Taylor
Youre welcome. I just remembered why I thought it was buggy. To run without optimizations (and therefore have line numbers in stack traces), I had to run:java -jar lib/jsdoc/jsrun.jar -opt -1 lib/run.jsAnd in that scenario, jsrun.jar would consider "-opt" the path.
Eric
ok, i'll keep that in mind. thanks
Dave Taylor