Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asset-smasher

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-smasher - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

6

CHANGELOG.md
# Asset Smasher Changelog
## 0.1.1 (June 12, 2012)
- Fix issue where assets could get processed multiple times when calling `compileSingleAsset`. When calling `compileSingleAsset`, an asset will not be recompiled if it has already been compiled. If it hasn't been compiled, any `require`d assets will be recompiled even if they've been compiled already.
- Add a `reset` method to `Smasher` to clear out all the asset metadata.
- Add a `reset` method to `Asset` to set it back to its before-compile state.
## 0.1.0
- Initial Release

@@ -41,2 +41,7 @@ var path = require('path');

},
reset:function () {
this.assetFilePath = this._assetFilePath;
this.contents = null;
this.compiled = false;
},
loadOriginalContents:function (cb, sync) {

@@ -43,0 +48,0 @@ var self = this;

60

lib/asset-smasher.js

@@ -144,7 +144,13 @@ var async = require('async');

/**
* Clear out the asset metadata.
*/
reset:function () {
this.bundle.clear();
},
/**
* Compile all the assets according to the options
*/
compileAssets:function (cb) {
this.reset();
var bundle = this.bundle;
bundle.clear();
var self = this;

@@ -182,2 +188,5 @@ async.waterfall([

*
* Will not compile an asset that's already been compiled. Call reset() first
* if you want to asset to be recompiled.
*
* @param assetFilePath Path to the asset file

@@ -202,28 +211,35 @@ */

var asset = this.bundle.addAsset(baseDir, assetFilePath);
async.waterfall([
function (wfCb) {
executePhase(self.phases.singleDiscovery, asset, wfCb);
},
function (a, wfCb) {
var dependencies = self.bundle.getRequiredFiles(assetFilePath).map(function (dependency) {
return self.bundle.getAsset(dependency);
});
dependencies.push(asset); // Add the final asset we're making to the end
async.forEachSeries(dependencies, function (dep, eachCb) {
executePhase(self.phases.compilation, dep, eachCb);
}, wfCb);
},
function (wfCb) {
executePhase(self.phases.postCompilation, asset, wfCb);
},
function (a, wfCb) {
executePhase(self.phases.output, asset, wfCb);
}
], cb);
if (!asset.compiled) {
async.waterfall([
function (wfCb) {
executePhase(self.phases.singleDiscovery, asset, wfCb);
},
function (a, wfCb) {
var dependencies = self.bundle.getRequiredFiles(assetFilePath).map(function (dependency) {
return self.bundle.getAsset(dependency);
});
dependencies.push(asset); // Add the final asset we're making to the end
async.forEachSeries(dependencies, function (dep, eachCb) {
dep.reset(); // Ensure the file gets compiled even if it's already been compiled before
executePhase(self.phases.compilation, dep, eachCb);
}, wfCb);
},
function (wfCb) {
executePhase(self.phases.postCompilation, asset, wfCb);
},
function (a, wfCb) {
executePhase(self.phases.output, asset, wfCb);
}
], cb);
} else {
cb(null, asset);
}
}
},
/**
* Find, but do not compile all the assets according to the options
* Find, but do not compile all the assets according to the options.
*
*/
findAssets:function (cb) {
this.reset();
var bundle = this.bundle;

@@ -230,0 +246,0 @@ var self = this;

{
"name": "asset-smasher",
"description": "Asset pre-processor, merger, and compressor.",
"version": "0.1.0",
"version": "0.1.1",
"author": "Jim Riecken <jriecken@gmail.com>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -300,4 +300,6 @@ # Asset Smasher

- `getProcessingOrderLogicalPaths()` - Get a list of the order in which assets should be processed in order to satisfy all dependencies. Only call this after finding/compiling assets.
- `reset()` - Reset the asset metadata.
The `Asset` object returned by `getAssetByLogicalPath` has the following properties:
The `Asset` object returned by `getAssetByLogicalPath` has the following properties (and one method):
- `logicalPath` - The logical path

@@ -308,2 +310,3 @@ - `hashedPath` - If `hash` is true, the hashed filename path, otherwise the same as `logicalPath`

- `compiledAssetFilePath` - The full path to the compiled asset file
- `reset()` - Set the asset back to its before-compile state (clear out contents, set name back to pre-transform name)

@@ -310,0 +313,0 @@ **Example**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc