I’m trying to run JSLint via V8.
- I downloaded and built the V8 shell using these instructions.
- The interactive shell
d8works, and passing a file to it executes that file.
Now I want to execute jslint.js and pass the name of the file to parse to it. I have tried
d8 jslint.js myfile.js
d8 jslint.js < myfile.js
d8 jslint.js -- myfile.js
No doubt the trouble lines in the end of jslint.js which uses the Rhino readline() function to get the command-line arguments. Has anyone modified this script to work in V8 or is there a generic way to have V8 pass arguments to it?
Update: Steve’s answer reminded me that I did find a way to compile JSLint into an executable much as Steve did, but I was hoping for something that was a little more portable for the other developers.
The d8 shell allows you to pass arguments on the command line by preceding them by ‘–‘.
I.e., in your case:
Everthing after ‘–‘ will be read as verbatim strings, so all other flags must go before that.
The command line arguments will be available to scripts as a global variable called “arguments” holding an array of strings.
(Instead of ‘–‘ you can use the synonymous ‘–js-arguments’).