Skip to content

Instantly share code, notes, and snippets.

@wavded
Last active January 26, 2016 00:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wavded/4958ef24c9ab6fa48269 to your computer and use it in GitHub Desktop.
Save wavded/4958ef24c9ab6fa48269 to your computer and use it in GitHub Desktop.
# 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