Skip to content

Instantly share code, notes, and snippets.

@wavded wavded/
Last active Jan 26, 2016

What would you like to do?
# 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')" > /dev/null; then
npm run build
# Archive artifact
if [ -d "dist" ]; then
cd dist
tar -zcf ../archive.tar.gz . || :
cd ..
tar -zcf archive.tar.gz --exclude=".git" --exclude=archive.tar.gz . || :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.