Created a compat.js file in build/, for browser compatiblity, moved trim() in

there. LESS builds to dist/ now.
This commit is contained in:
cloudhead 2010-03-27 02:24:39 -04:00
parent 41d701de1d
commit 3a474c9bae
3 changed files with 11 additions and 18 deletions

View File

@ -14,8 +14,8 @@ benchmark:
# Build less.js
#
SRC = lib/less
BUILD = build/less.js
BUILD_MIN = build/less.min.js
DIST = dist/less.js
DIST_MIN = dist/less.min.js
HEADER = build/header.js
VERSION = `cat VERSION`
@ -25,13 +25,13 @@ less:
${SRC}/parser.js\
${SRC}/functions.js\
${SRC}/tree/*.js\
${SRC}/browser.js > ${BUILD}
@@echo ${BUILD} built.
${SRC}/browser.js > ${DIST}
@@echo ${DIST} built.
min: less
@@echo Minifying...
@@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${BUILD_MIN}
@@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST_MIN}
@@java -jar build/compiler.jar\
--js ${BUILD} >> ${BUILD_MIN}
--js ${DIST} >> ${DIST_MIN}
.PHONY: test benchmark

5
build/compat.js Normal file
View File

@ -0,0 +1,5 @@
if (typeof(String.prototype.trim) !== "function") {
String.prototype.trim = function (str) {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};
}

View File

@ -1,12 +0,0 @@
if (typeof(String.prototype.trim) === "undefined") {
String.prototype.trim = function (str) {
var str = this.replace(/^\s+/, '');
for (var i = str.length - 1; i >= 0; i--) {
if (/\S/.test(str.charAt(i))) {
str = str.substring(0, i + 1);
break;
}
}
return str;
};
}