allow lint.sh to take a file as a command-line argument
authorDan Vanderkam <danvk@google.com>
Fri, 10 Aug 2012 15:38:17 +0000 (11:38 -0400)
committerDan Vanderkam <danvk@google.com>
Fri, 10 Aug 2012 15:38:17 +0000 (11:38 -0400)
lint.sh

diff --git a/lint.sh b/lint.sh
index 890820d..6c640ad 100755 (executable)
--- a/lint.sh
+++ b/lint.sh
@@ -1,8 +1,23 @@
 #!/bin/bash
+#
+# Usage:
+#   ./lint.sh [file.js]
+#
+# The zero-argument form lints everything.
+
 jsc_opts='maxerr:10000,devel:true,browser:true'
 rhino_opts='maxerr=10000,devel=true,browser=true'
 
-files=$(ls dygraph*.js | grep -v combined | grep -v dev.js);
+if [ $# -gt 1 ]; then
+  echo "Usage: $0 [file.js]"
+  exit 1
+fi
+
+if [ $# -eq 0 ]; then
+  files=$(ls dygraph*.js plugins/*.js | grep -v combined | grep -v dev.js)
+else
+  files=$1
+fi
 
 if [ -e /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc ]; then
   # use JSC (Safari/JavaScriptCore) to run JSHint -- much faster than Rhino.