Skip to content

Commit b72b69b

Browse files
patrick-tolosastrausr
authored andcommitted
Improved script tags in package.json
1 parent c5290c5 commit b72b69b

File tree

8 files changed

+42
-8
lines changed

8 files changed

+42
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ bin
77
*.map
88
!lib
99
test_cache/
10+
.nyc_output
11+
docs

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"jsdom": "^9.12.0",
3535
"jsdom-global": "2.1.1",
3636
"mocha": "^5.0.0",
37-
"nyc": "^13.0.1",
37+
"nyc": "^13.3.0",
3838
"sinon": "^6.1.4",
3939
"webpack-cli": "^3.2.1"
4040
},
@@ -48,17 +48,17 @@
4848
],
4949
"types": "types",
5050
"scripts": {
51-
"test": "set -e node_v=$(node --version)z\nif [[ \"${node_v%%.*z}\" == 'v4' ]]\nthen\nnpm run test-es5\nelse\nnpm run test-es6\nfi\nnpm run dtslint",
52-
"dtslint": "dtslint --expectOnly --localTs node_modules/typescript/lib types ",
51+
"test": "tools/scripts/test.sh",
52+
"dtslint": "tools/scripts/ditslint.sh",
5353
"lint": "eslint .",
54-
"compile": "node_modules/.bin/babel lib --out-dir lib-es5 --delete-dir-on-start --verbose",
55-
"test-es6": "which node && node node_modules/.bin/mocha --ui bdd -R spec --recursive test/",
56-
"test-es5": "node node_modules/.bin/mocha -R spec --recursive --require 'babel-register' --require 'babel-polyfill' test/",
57-
"docs": "npm run compile && node_modules/.bin/jsdoc -d docs -r -p lib/*"
54+
"compile": "tools/scripts/compile.sh",
55+
"coverage": "tools/scripts/test.es6.sh --coverage",
56+
"test-es6": "tools/scripts/test.es6.sh",
57+
"test-es5": "tools/scripts/test.es5.sh",
58+
"docs": "tools/scripts/docs.sh"
5859
},
5960
"optionalDependencies": {},
6061
"engines": {
6162
"node": ">=0.6"
6263
}
6364
}
64-

tools/scripts/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
babel lib --out-dir lib-es5 --delete-dir-on-start --verbose

tools/scripts/ditslint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dtslint --expectOnly --localTs node_modules/typescript/lib types

tools/scripts/docs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run compile && jsdoc -d docs -r -p lib/*

tools/scripts/test.es5.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
mocha -R spec --recursive --require 'babel-register' --require 'babel-polyfill' test/

tools/scripts/test.es6.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
COLLECT_COVERAGE=0;
2+
3+
for arg in "$@"
4+
do
5+
case $arg in
6+
--coverage)
7+
COLLECT_COVERAGE=1
8+
shift # Remove --initialize from processing
9+
esac
10+
done
11+
12+
if [ "$COLLECT_COVERAGE" -eq "1" ]; then
13+
echo 'Running code coverage test on ES6 code'
14+
nyc --reporter=text mocha --ui bdd -R spec --recursive test/
15+
exit;
16+
else
17+
echo 'Running tests on ES6 Code'
18+
mocha --ui bdd -R spec --recursive test/
19+
fi
20+

tools/scripts/test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
set -e node_v=$(node --version)z
2+
if [[ "${node_v%%.*z}" == 'v4' ]]
3+
then
4+
npm run test-es5
5+
else
6+
npm run test-es6
7+
fi
8+
npm run dtslint

0 commit comments

Comments
 (0)