Skip to content

Commit

Permalink
Add checkstyle as option to use checkstyle reporting jshint
Browse files Browse the repository at this point in the history
  • Loading branch information
levsa committed Mar 25, 2013
1 parent 34ccf8c commit cba785c
Show file tree
Hide file tree
Showing 3 changed files with 5,069 additions and 144 deletions.
12 changes: 10 additions & 2 deletions src/main/groovy/com/eriwen/gradle/js/tasks/JsHintTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ import org.gradle.api.tasks.OutputFile

class JsHintTask extends SourceTask {
private static final String JSHINT_PATH = 'jshint-rhino-r12.js'
private static final String JSHINT_CS_PATH = 'jshint-rhino-cs-r12.js'
private static final String TMP_DIR = "tmp${File.separator}js"
private static final ResourceUtil RESOURCE_UTIL = new ResourceUtil()
private final RhinoExec rhino = new RhinoExec(project)

@OutputFile def dest = new File(project.buildDir, "jshint.log")
@OutputFile def dest = new File(project.reportsDir, "jshint.log")
@Input def ignoreExitCode = true
@Input def outputToStdOut = false
@Input def checkstyle = false

File getDest() {
project.file(dest)
Expand All @@ -40,7 +42,13 @@ class JsHintTask extends SourceTask {
def run() {
final File jshintJsFile = RESOURCE_UTIL.extractFileToDirectory(
new File(project.buildDir, TMP_DIR), JSHINT_PATH)
final List<String> args = [jshintJsFile.canonicalPath]
final File jshintCsJsFile = RESOURCE_UTIL.extractFileToDirectory(
new File(project.buildDir, TMP_DIR), JSHINT_CS_PATH)
final File jsFile = jshintJsFile
if (checkstyle) {
jsFile = jshintCsJsFile
}
final List<String> args = [jsFile.canonicalPath]
args.addAll(source.files.collect { it.canonicalPath })
LinkedHashMap<String, Object> options = project.jshint.options
if (options != null && options.size() > 0) {
Expand Down
Loading

0 comments on commit cba785c

Please sign in to comment.