diff --git a/.gitignore b/.gitignore index ae4d30001c..c0531a409f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /node_modules /bower_components /dist +/tooling/node_modules diff --git a/.jscsrc b/.jscsrc index 0bf35ac188..4efa8669f4 100644 --- a/.jscsrc +++ b/.jscsrc @@ -23,6 +23,7 @@ "function", "typeof" ], + "excludeFiles": ["**/node_modules/**", "**/bower_components/**"], "requireSpaceBeforeBlockStatements": true, "requireParenthesesAroundIIFE": true, "requireSpacesInConditionalExpression": true, diff --git a/browser-tests/run.sh b/browser-tests/run.sh new file mode 100755 index 0000000000..f14d2efc85 --- /dev/null +++ b/browser-tests/run.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +npm i && \ +eval "npm test -- $@" + diff --git a/tooling/package.json b/tooling/package.json new file mode 100644 index 0000000000..dc5fd92e3e --- /dev/null +++ b/tooling/package.json @@ -0,0 +1,9 @@ +{ + "private": true, + "scripts": { + "lint": "jscs" + }, + "dependencies": { + "jscs": "^1.13.1" + } +} diff --git a/tooling/run.sh b/tooling/run.sh new file mode 100755 index 0000000000..8938820e45 --- /dev/null +++ b/tooling/run.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +PATHS="" +EXAMPLES_DIR="../examples/" + +for arg in "$@" +do +case $arg in + --framework=*) + PATHS+=" "$EXAMPLES_DIR$(echo $arg | awk '{split($0,a,"="); print a[2]}') + ;; +esac +done + +npm i && \ +eval "npm run lint -- -c ../.jscsrc $PATHS" diff --git a/travis-runner.sh b/travis-runner.sh index 61220f65b6..365c55108e 100755 --- a/travis-runner.sh +++ b/travis-runner.sh @@ -1,6 +1,14 @@ #!/bin/bash set -o pipefail + +get_changes () +{ + git remote add current https://github.com/tastejs/todomvc.git && \ + git fetch --quiet current && \ + git diff HEAD origin/master --name-only | awk 'BEGIN {FS = "/"}; {print $1 "/" $2 "/" $3}' | uniq | grep -v \/\/ | grep examples | awk -F '[/]' '{print "--framework=" $2}' +} + if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] then git submodule add -b gh-pages https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} site > /dev/null 2>&1 @@ -16,17 +24,16 @@ then # Any command that using GH_OAUTH_TOKEN must pipe the output to /dev/null to not expose your oauth token git push https://${GH_OAUTH_TOKEN}@github.com/${GH_OWNER}/${GH_PROJECT_NAME} HEAD:gh-pages > /dev/null 2>&1 else - git remote add current https://github.com/tastejs/todomvc.git && \ - git fetch current && \ - cd browser-tests/ && \ - npm i && \ - changes=$(git diff HEAD origin/master --name-only | awk 'BEGIN {FS = "/"}; {print $1 "/" $2 "/" $3}' | uniq | grep -v \/\/ | grep examples | awk -F '[/]' '{print "--framework=" $2}') + changes=$(get_changes) if [ "${#changes}" = 0 ] then exit 0 else - echo changes | xargs npm run test -- + cd tooling && \ + echo $changes | xargs ./run.sh && \ + cd ../browser-tests && \ + echo $changes | xargs ./run.sh fi exit $?