asset-smasher
Advanced tools
Comparing version 0.2.1 to 0.2.2
# Asset Smasher Changelog | ||
## 0.2.2 (November 7, 2012) | ||
- Ensure that concurrent requests for assets are correctly compiled by the connect middleware (Fixes #5) | ||
## 0.2.1 (September 17, 2012) | ||
@@ -4,0 +8,0 @@ |
var path = require('path'); | ||
var url = require('url'); | ||
var async = require('async'); | ||
var Smasher = require('./asset-smasher').Smasher; | ||
@@ -12,2 +13,3 @@ var staticMiddleware; | ||
if (options.serve) { | ||
this.compileQueue = async.queue(this.loadOrCompileAsset.bind(this), 1); | ||
this.smasher = new Smasher(options); | ||
@@ -20,3 +22,2 @@ this.findAssets(); | ||
execute:function (req, res, next) { | ||
var self = this; | ||
this.registerHelpers(res); | ||
@@ -34,8 +35,15 @@ if (!this.serve) { | ||
} else { | ||
this.smasher.compileSingleAsset(asset.assetFilePath, function (e) { | ||
// Assets must be compiled non-concurrently | ||
this.compileQueue.push({ | ||
req:req, | ||
res:res, | ||
asset:asset, | ||
next:next | ||
}, function (e) { | ||
// If there's an error, we need to continue the request | ||
if (e) { | ||
next(e); | ||
} else { | ||
self.serveAsset(req, res, next, asset); | ||
} | ||
// Otherwise the asset will be processed and next() will | ||
// have already been called. | ||
}); | ||
@@ -51,2 +59,19 @@ } | ||
}, | ||
loadOrCompileAsset:function(task, done) { | ||
var self = this; | ||
// Asset might have been compiled while we were waiting | ||
if (task.asset.compiled) { | ||
this.serveAsset(task.req, task.res, task.next, task.asset); | ||
done(); | ||
} else { | ||
this.smasher.compileSingleAsset(task.asset.assetFilePath, function (e) { | ||
if (e) { | ||
done(e); | ||
} else { | ||
self.serveAsset(task.req, task.res, task.next, task.asset); | ||
done(); | ||
} | ||
}); | ||
} | ||
}, | ||
serveAsset:function (req, res, next, asset) { | ||
@@ -53,0 +78,0 @@ staticMiddleware.send(req, res, next, { |
{ | ||
"name": "asset-smasher", | ||
"description": "Asset pre-processor, merger, and compressor.", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"author": "Jim Riecken <jriecken@gmail.com>", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
77307
1834
0