2 # usage (run from any directory) :
3 # env/jsc.sh /path/to/script.js
4 # or with jshint options:
5 # env/jsc.sh /path/to/script.js "{option1:true,option2:false,option3:25}"
7 alias jsc
="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
11 FILE_CONTENT
=$
(cat "${FILE}")
13 if [ -L
$BASH_SOURCE ]; then
14 ENV_HOME
="$( cd "$
( dirname "$(readlink "$BASH_SOURCE")" )" && pwd )"
16 ENV_HOME
="$( cd "$
( dirname "$BASH_SOURCE" )" && pwd )"
19 LINT_RESULT
=$
(jsc
"${ENV_HOME}"/jsc.js
-- "${FILE}" "${FILE_CONTENT}" "${OPTS}" "${ENV_HOME}")
21 ERRORS
=$
(echo ${LINT_RESULT} |
egrep [^\s
] -c
)
23 if [[ ${ERRORS} -ne
0 ]]; then
24 echo "[jshint] Error(s) in ${FILE}:"
25 printf "%s\n" "${LINT_RESULT}"
27 echo "[jshint] ${FILE} passed!"
30 exit $
((0 + ${ERRORS}))