Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*~
\#*\#
.DS_Store
dist
57 changes: 57 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
BUILD_DIR = build

PREFIX = .
SRC_DIR = ${PREFIX}/src
DIST_DIR = ${PREFIX}/dist


JS_ENGINE ?= `which node nodejs`
COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
POST_COMPILER = ${JS_ENGINE} ${BUILD_DIR}/post-compile.js

SRC = ${SRC_DIR}/jsonselect.js
DIST = ${DIST_DIR}/jsonselect.js
DIST_MIN = ${DIST_DIR}/jsonselect.min.js

${DIST_DIR}:
@@mkdir -p ${DIST_DIR}

all: hint project min
@@echo "Project build complete."

project: ${DIST}

${DIST}: ${SRC} | ${DIST_DIR}
@@echo "Building" ${DIST}
@@echo ${SRC}
@@cat ${SRC} > ${DIST};


min: project ${DIST_MIN}

${DIST_MIN}: ${DIST}
@@if test ! -z ${JS_ENGINE}; then \
echo "Minifying Project" ${DIST_MIN}; \
${COMPILER} ${DIST} > ${DIST_MIN}.tmp; \
${POST_COMPILER} ${DIST_MIN}.tmp > ${DIST_MIN}; \
rm -f ${DIST_MIN}.tmp; \
else \
echo "You must have NodeJS installed in order to minify Project."; \
fi


hint:
@@if test ! -z ${JS_ENGINE}; then \
echo "Hinting Project"; \
${JS_ENGINE} build/jshint-check.js; \
else \
echo "Nodejs is missing"; \
fi


clean:
@@echo "Removing Distribution directory:" ${DIST_DIR}
@@rm -rf ${DIST_DIR}


.PHONY: all project hint min
41 changes: 41 additions & 0 deletions build/jshint-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var JSHINT = require("./lib/jshint").JSHINT,
print = require("sys").print,
src = require("fs").readFileSync("src/jsonselect.js", "utf8");

JSHINT(src, { evil: true, forin: true, maxerr: 100 });

var ok = {

// w.reason
"Expected an identifier and instead saw 'undefined' (a reserved word).": true,
"Use '===' to compare with 'null'.": true,
"Use '!==' to compare with 'null'.": true,
"Expected an assignment or function call and instead saw an expression.": true,
"Expected a 'break' statement before 'case'.": true,
"'e' is already defined.": true,
// w.raw
"Expected an identifier and instead saw \'{a}\' (a reserved word).": true
};

var e = JSHINT.errors,
found = 0,
w;

for ( var i = 0; i < e.length; i++ ) {
w = e[i];

//console.log( w );
if ( !ok[ w.reason ] && !ok[ w.raw ] ) {
found++;

print( "\n " + found + ". Problem at line " + w.line + " character " + w.character + ": " + w.reason );
print( "\n" + w.evidence );
}
}

if ( found > 0 ) {
print( "\n\n" + found + " Error(s) found.\n" );

} else {
print( "JSHint check passed.\n" );
}
Loading