Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

implemented q-style wrapper and adjusted the build scripts

  • Loading branch information...
commit d93bceb05f30ffdcdebbbb19d3619d7e4c008933 1 parent 821f295
@michaelsbradleyjr michaelsbradleyjr authored
View
1  .npmignore
@@ -20,6 +20,7 @@ bin
scripts
spec
src
+support
.npmignore
.travis.yml
project.clj
View
2  package.json
@@ -26,7 +26,7 @@
"url": "https://raw.github.com/swannodette/mori/master/epl-v10.html"
}
],
- "main": "./mori.node.js",
+ "main": "./mori.js",
"repository": {
"type": "git",
"url": "git://github.com/swannodette/mori.git"
View
10 scripts/build.ps1
@@ -1,11 +1,11 @@
+lein deps
lein cljsbuild clean
lein cljsbuild once release
$moribarejs = Get-Content mori.bare.js
+$wrapperbeg = Get-Content support/wrapper.beg.txt
+$wrapperend = Get-Content support/wrapper.end.txt
ni "mori.js" -type file -force
-ac "mori.js" "(function() {"
+ac "mori.js" $wrapperbeg
ac "mori.js" $moribarejs
-ac "mori.js" "}).call(this);"
-ni "mori.node.js" -type file -force
-ac "mori.node.js" $moribarejs
-ac "mori.node.js" ";module.exports = this.mori;"
+ac "mori.js" $wrapperend
rm mori.bare.js
View
6 scripts/build.sh
@@ -5,11 +5,7 @@
echo "Finalizing mori.js"
-(echo "(function() {"; cat mori.bare.js; echo "}).call(this);") > mori.js
-
-echo "Finalizing mori.node.js"
-
-(cat mori.bare.js; echo ";module.exports = this.mori;") > mori.node.js
+(cat support/wrapper.beg.txt; cat mori.bare.js; cat support/wrapper.end.txt) > mori.js
echo "Deleting mori.bare.js"
View
2  scripts/clean.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-rm -f mori.node.js mori.js
+rm -f mori.js
./bin/lein_prefer cljsbuild clean
View
1  support/wrapper.beg.txt
@@ -0,0 +1 @@
+(function(definition){if(typeof exports==="object"){module.exports=definition();}else if(typeof define==="function"&&define.amd){define(definition);}else{mori=definition();}})(function(){return function(){
View
1  support/wrapper.end.txt
@@ -0,0 +1 @@
+;return this.mori;}.call({});});
View
32 support/wrapper.js
@@ -1,10 +1,32 @@
-function test() {
+(function (definition) {
+ // This file will function properly as a <script> tag, or a module
+ // using CommonJS and NodeJS or RequireJS module formats. In
+ // Common/Node/RequireJS, the module exports the mori API and when
+ // executed as a simple <script>, it creates a mori global
+ // instead.
- var testME;
+ // Wrapper gratefully adapted from:
+ // https://github.com/kriskowal/q/blob/master/q.js
- var REPLACEME;
+ // CommonJS
+ if (typeof exports === "object") {
+ module.exports = definition();
- function allIwantIsMinify() {
+ // RequireJS
+ } else if (typeof define === "function" && define.amd) {
+ define(definition);
+ // <script>
+ } else {
+ mori = definition();
}
-}
+})(function () {
+ return function () {
+
+ var REPLACE_WITH_MORI_BARE_JS;
+
+ ;return this.mori;
+
+ }.call({});
+
+});
View
2  support/wrapper.min.js
@@ -1 +1 @@
-function test(){var testME;var REPLACEME;function allIwantIsMinify(){}}
+(function(definition){if(typeof exports==="object"){module.exports=definition();}else if(typeof define==="function"&&define.amd){define(definition);}else{mori=definition();}})(function(){return function(){var REPLACE_WITH_MORI_BARE_JS;return this.mori;}.call({});});
Please sign in to comment.
Something went wrong with that request. Please try again.