Skip to content

Commit

Permalink
Refactor npm scripts for mocha
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Aug 2, 2016
1 parent 9d9642c commit 59fdea9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lighthouse-core/closure/closure-type-checking.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ gulp.task('js-compile', function() {
checks_only: true,
language_in: 'ECMASCRIPT6_STRICT',
language_out: 'ECMASCRIPT5_STRICT',
warning_level: 'VERBOSE',
warning_level: process.env.CI ? 'QUIET' : 'VERBOSE',
jscomp_error: [
'checkTypes',
'conformanceViolations'
Expand Down
15 changes: 15 additions & 0 deletions lighthouse-core/scripts/run-mocha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

flag=$1

function _runmocha() {
mocha $2 $__node_harmony $(find $1/test -name '*.js') --timeout 60000;
}

if [ "$flag" == '--watch' ]; then
_runmocha '*' '--watch'
elif [ "$flag" == '--cli' ]; then
_runmocha 'lighthouse-cli'
else
_runmocha 'lighthouse-cli' && _runmocha 'lighthouse-core'
fi
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
"node": ">=5"
},
"scripts": {
"//": "// passing through tasks to core",
"lint": "eslint .",
"lint": "[ \"$CI\" = true ] && eslint --quiet . || eslint .",
"smoke": "lighthouse-cli/scripts/run-smoke-tests.sh",
"coverage": "node $(echo $__node_harmony) $(npm bin)/istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*.js') --timeout 60000",
"coverage": "node $__node_harmony $(npm bin)/istanbul cover -x \"**/third_party/**\" _mocha -- $(find */test -name '*.js') --timeout 60000 --reporter progress",
"coveralls": "npm run coverage && cat ./coverage/lcov.info | coveralls",
"start": "node ./lighthouse-cli/index.js",
"test": "npm run lint --silent && npm run unit && npm run closure",
"cli-unit": "mocha $(echo $__node_harmony) $(find lighthouse-cli/test lighthouse-core/test -name '*.js') --timeout 60000",
"unit": "npm run cli-unit",
"cli-unit": "lighthouse-core/scripts/run-mocha.sh --cli",
"unit": "lighthouse-core/scripts/run-mocha.sh --default",
"closure": "cd lighthouse-core && closure/closure-type-checking.js",
"watch": "find lighthouse-core lighthouse-cli -name '*.js' -not -path '*/node_modules/*' -not -path '*/extension/*' | entr npm run unit",
"watch": "lighthouse-core/scripts/run-mocha.sh --watch",
"chrome": "lighthouse-core/scripts/launch-chrome.sh"
},
"devDependencies": {
Expand Down

0 comments on commit 59fdea9

Please sign in to comment.