2

I'm trying to run JSLint via V8.

  • I downloaded and built the V8 shell using these instructions.
  • The interactive shell d8 works, 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.

2 Answers 2

3

The d8 shell allows you to pass arguments on the command line by preceding them by '--'. I.e., in your case:

  d8 jslint.js -- myfile.js

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').

Sign up to request clarification or add additional context in comments.

1 Comment

This was broken for a while but is fixed again.
2

You could possibly have a look at my attempt to run JSLint using v8 at http://blog.stevenreid.co.uk/2011/06/27/jslint-command-line-tool-powered-by-v8/.

The command line application compiles JSLint directly into the binary. All JSlint options are supported. Multiple source files can be linted as well as input from stdin.

5 Comments

I was unable to build FOX. The make command dies saying it cannot find -lXext, -lGL, and -lGLU. Any ideas?
Even though the build failed, you should hopefully have the 'reswrap' executable now. That's all that is needed.
Okay, now it's complaining that v8preparser.a is incompatible. This is probably because I am running 64-bit and had to specify --arch=x64 when building v8. Is there a way to pass that to your scons script? The same argument is kicked out by scons.
Sorry no, the scons script supports 32-bit only atm.
Okay no worries. Thanks for the effort.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.