Skip to content


Subversion checkout URL

You can clone with
Download ZIP


New buildr task for npm version of jslint. Works on Windows, OSX and unix. #1

wants to merge 1 commit into from

2 participants


Added a new buildr task for the npm version of jslint.


I'm not a fan of this approach. Since Node.js and npm are available on all platforms, shouldn't the npm version of JSLint work the same on all of them?


I agree that they should work the same on all platforms. I can't tell if this is a node/npm issue or an ant issue. Personally I am leaning towards it being an ant issue because others have reported similar issues with ant's exec task on windows. The issue seems to only occur when calling a batch file that in turn calls other commands that create output to stdout. It seems ant is capturing the stdout of the batch file, but can't see the stdout from it's child processes because of the way it invokes the batch file. (Googling around you'll see others have had a similar issue with perl scripts used in batch files that are called by ant on windows. As well, there is this stackoverflow link that I commented on...

Regardless... it's an issue that needs to be worked around. I would rather not work around it with the approach I came up with... but it seems to be the only solution today.

Unfortunately I don't have the interest/time to look into this problem further... So I am not that concerned if you accept the pull request or not. If others find the workaround/approach interesting, they can use it. And you and others have the info if you want to research this problem further with related tasks for buildr on windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 75 additions and 0 deletions.
  1. +4 −0
  2. +71 −0 macros/jslint.xml
@@ -26,6 +26,10 @@ buildr.jshint = jshint.js
buildr.jshint.path = ${buildr.lib.dir}/${buildr.jshint}
buildr.jshint.opts = curly=true,forin=true,latedef=true,noempty=true,undef=true,rhino=false
+# JSLint
+buildr.jslint.opts=--white --undef --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars
# JsTestDriver
buildr.jstestdriver = JsTestDriver-1.3.3d.jar
buildr.jstestdriver.path = ${buildr.lib.dir}/${buildr.jstestdriver}
71 macros/jslint.xml
@@ -0,0 +1,71 @@
+<project name="JSLint">
+ <!--Assumes jslint command is in your $PATH (or %PATH% on windows).-->
+ <!--jslint can be installed via npm. For example `npm install -g jslint`-->
+ <property name="buildr.jslint.options"
+ value="--white --undef --nomen --regexp --plusplus --bitwise --newcap --sloppy --vars" />
+ <!--On windows, the jslint command must have .cmd extension in order for ant to execute it.-->
+ <condition property="buildr.jslint.osCommand" value="${buildr.jslint.command}.cmd">
+ <os family="windows"/>
+ </condition>
+ <condition property="buildr.jslint.osCommand" value="${buildr.jslint.command}">
+ <or>
+ <os family="unix"/>
+ <os family="mac"/>
+ </or>
+ </condition>
+ <macrodef name="jslint">
+ <attribute name="options" default="${buildr.jslint.options}"/>
+ <attribute name="failonerror" default="true" />
+ <element name="jsfiles" implicit="true"/>
+ <sequential>
+ <echo>Validating with JSLint</echo>
+ <!--Note: jslint needs to be executed/called differently on windows-->
+ <!--Unix version of applying jslint to each file-->
+ <apply executable="${buildr.jslint.osCommand}" failonerror="@{failonerror}" osfamily="unix">
+ <jsfiles/>
+ <arg line="@{options} "/>
+ <srcfile/>
+ </apply>
+ <!--Mac version of applying jslint to each file (same as unix)-->
+ <apply executable="${buildr.jslint.osCommand}" failonerror="@{failonerror}" osfamily="mac">
+ <jsfiles/>
+ <arg line="@{options} "/>
+ <srcfile/>
+ </apply>
+ <!--Windows version of applying jslint to each file-->
+ <apply executable="${buildr.jslint.osCommand}" failonerror="@{failonerror}" osfamily="windows">
+ <jsfiles/>
+ <arg line="@{options} "/>
+ <srcfile/>
+ <!--Hack Note: The following arg is only necessary on windows in order to see all -->
+ <!-- stdout and stderr. -->
+ <!-- - On windows, jslint is a batch file that calls node. -->
+ <!-- - As expected the batch file's stdout and stderror is reported by ant. -->
+ <!-- - However the stdout from node is not passed through.(frustrating!!!!) -->
+ <!--The apply task's output and error attributes don't work in this situation. -->
+ <!--The following is a hack I figured out to view the jslint stdout and stderror output.-->
+ <!--(after all - it's useful to see the actual errors reported by jslint!) -->
+ <!--Next arg: forces node's stderror and stdout to a temporary file-->
+ <arg line=" &gt; _buildr_redirect.out 2&lt;&amp;1"/>
+ <!--Next arg: If jslint exits with an error, then output the temporary file to stdout, -->
+ <!-- delete the temporary file and finally exit with error level 1 so that -->
+ <!-- the apply task can catch the error if @failonerror="true" -->
+ <arg line=" || (type _buildr_redirect.out &amp; del _buildr_redirect.out &amp; exit /b 1)"/>
+ <!--Next arg: Otherwise, just type the temporary file and delete it-->
+ <arg line=" &amp; type _buildr_redirect.out &amp; del _buildr_redirect.out &amp;"/>
+ </apply>
+ </sequential>
+ </macrodef>
Something went wrong with that request. Please try again.