Last active
January 26, 2016 00:12
-
-
Save wavded/4958ef24c9ab6fa48269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Node build script that runs cloc, cpd, lint, test and coverage for Jenkins | |
# | |
# Outside tools include: | |
# jscpd: npm i jscpd -g | |
# cloc: npm i cloc -g | |
# eslint: npm i eslint -g | |
set -x | |
export NODE_ENV=production | |
# Clean directory (except node_modules) | |
git clean -dfx -e node_modules | |
# LOC reporting (SLOCCount plugin) | |
cloc --by-file --xml --out=cloc.xml --exclude-dir=node_modules,bower_components,vendor . | |
# Copy-paste detection (DRY plugin) | |
jscpd -e {**/node_modules/**,**/vendor/**,**/bower_components/**,**/*.min.*} -o cpd.xml | |
# Install shrinkwrapped deps and run any lifecycle hooks | |
npm install | |
# Run tests/coverage (TAP and Cobertura plugins) | |
npm run ci-test || : | |
# Run lint tools (Checkstyle plugin) | |
eslint -f checkstyle modules clientapp public src *.js > checkstyle-result.xml | |
# Run build script if exists | |
if node -e "require('./package.json').scripts.build.toString" > /dev/null; then | |
npm run build | |
fi | |
# Archive artifact | |
if [ -d "dist" ]; then | |
cd dist | |
tar -zcf ../archive.tar.gz . || : | |
cd .. | |
else | |
tar -zcf archive.tar.gz --exclude=".git" --exclude=archive.tar.gz . || : | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment