Merge branch 'master' of https://github.com/danvk/dygraphs into connect-separated...
[dygraphs.git] / jshint / env / jsc.sh
... / ...
CommitLineData
1#!/bin/sh
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}"
6
7alias jsc="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
8FILE="${1}"
9OPTS="${2}"
10
11FILE_CONTENT=$(cat "${FILE}")
12
13if [ -L $BASH_SOURCE ]; then
14 ENV_HOME="$( cd "$( dirname "$(readlink "$BASH_SOURCE")" )" && pwd )"
15else
16 ENV_HOME="$( cd "$( dirname "$BASH_SOURCE" )" && pwd )"
17fi
18
19LINT_RESULT=$(jsc "${ENV_HOME}"/jsc.js -- "${FILE}" "${FILE_CONTENT}" "${OPTS}" "${ENV_HOME}")
20
21ERRORS=$(echo ${LINT_RESULT} | egrep [^\s] -c)
22
23if [[ ${ERRORS} -ne 0 ]]; then
24 echo "[jshint] Error(s) in ${FILE}:"
25 printf "%s\n" "${LINT_RESULT}"
26else
27 echo "[jshint] ${FILE} passed!"
28fi
29
30exit $((0 + ${ERRORS}))