Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

wrap dev version

  • Loading branch information...
commit 69465a7c4c4b217ca51d9813cb5685454022476f 1 parent 30fd914
@Swaagie Swaagie authored
Showing with 29 additions and 3 deletions.
  1. +12 −3 lib/square.js
  2. +17 −0 tests/fixtures/wrap-square.json
View
15 lib/square.js
@@ -126,6 +126,7 @@ Square.prototype.use = function use (layer) {
// check if we this middleware is already configured
if (!this.has(layer)) this.middleware.push(layer);
+
return this;
};
@@ -511,7 +512,15 @@ Square.prototype.build = function build (extension, groupsout, fn) {
var layers = self.middleware.slice(0)
, errors = []
, groupCount = collection.groupCount || 1
- , backup;
+ , backup
+
+ // check if there is a requirement to wrap the code, if so apply always
+ , wrap = _.find(layers, function checkForWrap (middleware) {
+ if (middleware.name === 'leak') {
+ layers.splice([layers.indexOf(middleware)],1);
+ return middleware;
+ }
+ });
/**
* Simple iteration helper function to process the middleware.
@@ -568,7 +577,7 @@ Square.prototype.build = function build (extension, groupsout, fn) {
// you don't really want to write both the minified version and a regular
// version as you output 2 versions of your data, dev and minified
collection.extension = extension;
- iterate(null, collection);
+ wrap.call(this, collection, iterate);
// stdout shouldn't receive dev shizzle
if (!this.stdout) this.write(collection, 'dev', doneGroup);
@@ -914,7 +923,7 @@ Square.prototype.merge = function merge (extension, groupsout) {
);
}, function done (err) {
if (err) {
- // Remove merge listener, otherwise while
+ // Remove merge listener, otherwise while
// watching we will get mulitple builds.
self.removeAllListeners('merge');
View
17 tests/fixtures/wrap-square.json
@@ -0,0 +1,17 @@
+{
+ "configuration": {
+ "dist": "/tmp/test.{type}.{ext}",
+ "plugins": {
+ "wrap": {
+ "header": "(function() {",
+ "footer": "})();",
+ "leaks": false
+ }
+ }
+ },
+ "bundle": {
+ "basic.js": {
+ "description": "wrap simple js to test the wrapper"
+ }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.