Permalink
Browse files

Improves make tasks and test runner

  • Loading branch information...
1 parent b842ec8 commit 9c180868be31bc4fb5cde05291df4dc2484ca604 @ixti ixti committed Dec 9, 2011
Showing with 40 additions and 7 deletions.
  1. +31 −7 Makefile
  2. +6 −0 package.json
  3. +3 −0 test/test-helper.js
View
38 Makefile
@@ -1,16 +1,27 @@
-.SILENT: test test-functional test-issues
+PATH := ./node_modules/.bin:${PATH}
-
-PATH := ./node_modules/.bin:${PATH}
-
-PROJECT = $(notdir ${PWD})
-TMP_DIR = /tmp/${PROJECT}-$(shell date +%s)
+PROJECT := $(notdir ${PWD})
+TMP_PATH := /tmp/${PROJECT}-$(shell date +%s)
REMOTE_NAME ?= origin
REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url)
+CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master)
+GITHUB_NAME := nodeca/js-yaml
+SRC_URL_FMT := https://github.com/${GITHUB_NAME}/blob/${CURR_HEAD}/{file}\#L{line}
+
+lint:
+ @if test ! `which jslint` ; then \
+ echo "You need 'jslint' installed in order to generate docs." >&2 ; \
+ echo " $ make dev-deps" >&2 ; \
+ exit 128 ; \
+ fi
+ # (node) -> Node.JS compatibility mode
+ # (indent) -> indentation level (2 spaces)
+ # (nomen) -> tolerate underscores in identifiers (e.g. `var _val = 1`)
+ jslint --node --nomen --indent=2 ./lib/*.js ./lib/**/*.js
-test: test-functional test-issues
+test: lint test-issues test-functional
test-functional:
echo
@@ -28,6 +39,13 @@ test-issues:
node ./test/issues/run.js
echo
+dev-deps:
+ @if test ! `which npm` ; then \
+ echo "You need 'npm' installed." >&2 ; \
+ echo " See: http://npmjs.org/" >&2 ; \
+ exit 128 ; \
+ fi
+ npm install --dev
build: browserify uglify
@@ -60,3 +78,9 @@ gh-pages:
git remote add remote ${REMOTE_REPO} && \
git push --force remote +master:gh-pages
rm -rf ${TMP_DIR}
+
+todo:
+ grep 'TODO' -n -r ./lib 2>/dev/null || test true
+
+.PHONY: test lint dev-deps gh-pages todo
+.SILENT: todo test test-functional test-issues
View
6 package.json
@@ -13,6 +13,12 @@
"bin" : { "jsyaml": "bin/js-yaml.js" },
"main" : "./index.js",
+ "scripts" : {
+ "test" : "make test"
+ },
+ "devDependencies" : {
+ "jslint" : "https://github.com/reid/node-jslint/tarball/6131ebf5713274871b89735105e3286131804771"
+ },
"engines" : { "node": "> 0.4.11" }
}
View
3 test/test-helper.js
@@ -136,6 +136,9 @@ helper.run = function run(root, regexp) {
console.log(colorize(90, '----' + ' (' + total + ') ' +
' P:' + stats.pass + ' W:' + stats.warn +
' F:' + stats.fail + ' E:' + stats.error));
+
+ // set correct error code on exit
+ process.exit((stats.warn + stats.fail + stats.error) > 0 ? 1 : 0);
};

0 comments on commit 9c18086

Please sign in to comment.