Skip to content
Browse files

move browser build to bash script, add pack underscore task

  • Loading branch information...
1 parent 353bdaf commit 16a0326f1e93c0425094859f1efcf58e025f7eed @paularmstrong paularmstrong committed Sep 30, 2011
Showing with 65 additions and 46 deletions.
  1. +1 −46 Makefile
  2. +64 −0 scripts/browser.sh
View
47 Makefile
@@ -1,55 +1,10 @@
-BROWSER_FILE = "dist/browser/swig.js"
-TEMP_FILE = "dist/.swig.js"
-
all:
@npm install -d
@cp scripts/githooks/* .git/hooks/
@chmod -R +x .git/hooks/
browser:
- @rm -rf dist/browser
- @mkdir -p dist/browser
- @cat dist/header.js >> $(BROWSER_FILE)
- @echo "swig = (function () {" >> $(BROWSER_FILE)
- @echo "var swig = {}," >> $(BROWSER_FILE)
- @echo " dateformat = {}," >> $(BROWSER_FILE)
- @echo " filters = {}," >> $(BROWSER_FILE)
- @echo " helpers = {}," >> $(BROWSER_FILE)
- @echo " parser = {}," >> $(BROWSER_FILE)
- @echo " tags = {};" >> $(BROWSER_FILE)
-
- @echo "(function (exports) {" >> $(BROWSER_FILE)
- @cat index.js >> $(BROWSER_FILE)
- @echo "})(swig);" >> $(BROWSER_FILE)
-
- @echo "(function (exports) {" >> $(BROWSER_FILE)
- @cat lib/dateformat.js >> $(BROWSER_FILE)
- @echo "})(dateformat);" >> $(BROWSER_FILE)
-
- @echo "(function (exports) {" >> $(BROWSER_FILE)
- @cat lib/filters.js >> $(BROWSER_FILE)
- @echo "})(filters);" >> $(BROWSER_FILE)
-
- @echo "(function (exports) {" >> $(BROWSER_FILE)
- @cat lib/helpers.js >> $(BROWSER_FILE)
- @echo "})(helpers);" >> $(BROWSER_FILE)
-
- @echo "(function (exports) {" >> $(BROWSER_FILE)
- @cat lib/parser.js >> $(BROWSER_FILE)
- @echo "})(parser);" >> $(BROWSER_FILE)
-
- @echo "(function (exports) {" >> $(BROWSER_FILE)
- @cat lib/tags.js >> $(BROWSER_FILE)
- @echo "})(tags);" >> $(BROWSER_FILE)
-
- @echo "return swig;" >> $(BROWSER_FILE)
- @echo "})();" >> $(BROWSER_FILE)
-
- @cp $(BROWSER_FILE) $(TEMP_FILE)
- @sed "/require/d" <$(TEMP_FILE) > $(BROWSER_FILE)
- @rm $(TEMP_FILE)
-
- @node_modules/uglify-js/bin/uglifyjs $(BROWSER_FILE) > dist/browser/swig.min.js
+ @scripts/browser.sh
test:
@node tests/speed.js
View
64 scripts/browser.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+function package() {
+ if [[ $1 == 'pack' ]]; then
+ BROWSER_FILE="dist/browser/swig.pack.js"
+ TEMP_FILE="dist/.swig.pack.js"
+ MIN_FILE="dist/browser/swig.pack.min.js"
+ else
+ BROWSER_FILE="dist/browser/swig.js"
+ TEMP_FILE="dist/.swig.js"
+ MIN_FILE="dist/browser/swig.min.js"
+ fi
+
+ cat dist/header.js >> $BROWSER_FILE
+ echo "swig = (function () {" >> $BROWSER_FILE
+ echo "var swig = {}," >> $BROWSER_FILE
+ echo "dateformat = {}," >> $BROWSER_FILE
+ echo "filters = {}," >> $BROWSER_FILE
+ echo "helpers = {}," >> $BROWSER_FILE
+ echo "parser = {}," >> $BROWSER_FILE
+ echo "tags = {};" >> $BROWSER_FILE
+
+ if [[ $1 == 'pack' ]]; then
+ cat node_modules/underscore/underscore.js >> $BROWSER_FILE
+ fi
+
+ echo "(function (exports) {" >> $BROWSER_FILE
+ cat index.js >> $BROWSER_FILE
+ echo "})(swig);" >> $BROWSER_FILE
+
+ echo "(function (exports) {" >> $BROWSER_FILE
+ cat lib/dateformat.js >> $BROWSER_FILE
+ echo "})(dateformat);" >> $BROWSER_FILE
+
+ echo "(function (exports) {" >> $BROWSER_FILE
+ cat lib/filters.js >> $BROWSER_FILE
+ echo "})(filters);" >> $BROWSER_FILE
+
+ echo "(function (exports) {" >> $BROWSER_FILE
+ cat lib/helpers.js >> $BROWSER_FILE
+ echo "})(helpers);" >> $BROWSER_FILE
+
+ echo "(function (exports) {" >> $BROWSER_FILE
+ cat lib/parser.js >> $BROWSER_FILE
+ echo "})(parser);" >> $BROWSER_FILE
+
+ echo "(function (exports) {" >> $BROWSER_FILE
+ cat lib/tags.js >> $BROWSER_FILE
+ echo "})(tags);" >> $BROWSER_FILE
+
+ echo "return swig;" >> $BROWSER_FILE
+ echo "})();" >> $BROWSER_FILE
+
+ cp $BROWSER_FILE $TEMP_FILE
+ sed "/require/d" <$TEMP_FILE > $BROWSER_FILE
+ rm $TEMP_FILE
+
+ node_modules/uglify-js/bin/uglifyjs $BROWSER_FILE > $MIN_FILE
+}
+
+rm -rf dist/browser
+mkdir -p dist/browser
+package
+package "pack"

0 comments on commit 16a0326

Please sign in to comment.
Something went wrong with that request. Please try again.