Execute coffeelint.js with RhinoShellExec?

(Brice Ruth) #1

Good morning!

I’ve been looking at this: http://gradle.1045684.n5.nabble.com/State-of-javascript-stuff-in-master-td5709818.html and trying to figure out how best to use the RhinoShellExec (http://www.gradle.org/docs/current/groovydoc/org/gradle/plugins/javascript/rhino/RhinoShellExec.html) to execute coffeelint.js (https://github.com/clutchski/coffeelint/blob/master/lib/coffeelint.js). Right now, I have this:

task lintCoffeeScript(type: RhinoShellExec) {

script = “lib/coffeelint.js”

scriptArgs = ["-r", “web-app/js/src”] }

Which doesn’t fail … unfortunately, it doesn’t appear to actually be executing coffeelint.js properly. I’m not sure if I’m running into a node/rhino issue (I can npm install -g coffeelint && coffeelint -r web-app/js/src), or if I need to configure RhinoShellExec with more. When I crack open coffeelint.js, I see that it’s doing a require(‘coffee-script’) - which I’m not sure how/where that would be satisfied (though I’m not seeing any errors:

All projects evaluated. Selected primary task ‘lintCoffeeScript’ Tasks to be executed: [task ‘:lintCoffeeScript’] :lintCoffeeScript Task ‘:lintCoffeeScript’ has not declared any outputs, assuming that it is out-of-date. Starting process ‘command ‘/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java’’. Working directory: /Users/USER_NAME/Projects/PROJECT_DIR Command: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java -Dfile.encoding=MacRoman -cp /Users/USER_NAME/.gradle/caches/artifacts-14/filestore/org.mozilla/rhino/1.7R3/jar/3bff1e632c665f8cf2d438f77a9f4d0758277db5/rhino-1.7R3.jar org.mozilla.javascript.tools.shell.Main /Users/USER_NAME/Projects/PROJECT_DIR/lib/coffeelint.js -r web-app/js/src An attempt to initialize for well behaving parent process finished. Successfully started process ‘command ‘/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java’’ Process ‘command ‘/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java’’ finished with exit value 0 (state: SUCCEEDED)


Can anyone give me a hand with this? Ideally, if the coffee-script dependency is all that’s needed, I am using CoffeeScriptCompile from plugin ‘coffeescript-base’ as well, so maybe there’s a way to pull the dependency from there?

Any assistance or pointers would be much appreciated!!

(Luke Daley) #2

The coffeelint site is down, so it’s hard to get info.

Is coffeelint designed to be run outside of a node.js environment?

(Brice Ruth) #3

Well, that doesn’t help :slight_smile: It was up the other day. Here’s the github site for it:


I’m not sure if it’s designed to run outside of a node.js environment … I did open up the lib/coffeelint.js in the GitHub repo to see if I could figure out any obvious indications that it was, but I probably don’t know what to look for.

(Luke Daley) #4

It does work in a JS env, but you need a Rhino driver.

The coffeelint.js file is not an “executable script”. It’s a library that exposes an API. You need to write a small driver JS program that calls this API.

This script needs to somehow get the code to be analysed into a string, and call this API.

Rhino provides language extensions for doing IO, as JavaScript cannot do this on its own. See: https://developer.mozilla.org/en-US/docs/Rhino/Shell