asset-smasher
Advanced tools
Comparing version 0.2.8 to 0.2.9
# Asset Smasher Changelog | ||
## 0.2.9 (April 29, 2013) | ||
- Ignore `require_dir` directive in manifest file if the required directory doesn't exist. Previously this would throw an EMFILE and was inconsistent with what `require` and `require_tree` did (which was ignore the directive). (Fixes #13) | ||
- Add two additional options, `--verbose` and `--noclean`. `--verbose` will log information about what's going on to the console, while `--noclean` will not delete the output directory when running the tool (by default the output directory will be cleared). (Fixes #13) | ||
## 0.2.8 (April 28, 2013) | ||
@@ -4,0 +9,0 @@ |
var async = require('async'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var rimraf = require('rimraf'); | ||
var _ = require('underscore'); | ||
@@ -22,2 +24,4 @@ | ||
var setImmediateCompat = global.setImmediate || process.nextTick; | ||
// Get "exists" from the right place | ||
var existsCompat = fs.exists || path.exists; | ||
@@ -50,5 +54,10 @@ function executePhase(phase, target, cb) { | ||
}); | ||
options.outputTo = path.resolve(options.outputTo); | ||
// Remember the output location | ||
this.outputTo = options.outputTo = path.resolve(options.outputTo); | ||
// Remember the asset dirs | ||
this.paths = options.paths; | ||
// Remember whether to not nuke the output directory | ||
this.noclean = options.noclean; | ||
// Are we outputing verbose logging info | ||
this.verbose = options.verbose; | ||
// Create the asset bundle | ||
@@ -99,3 +108,4 @@ var bundle = this.bundle = new AssetBundle(); | ||
paths:this.paths, | ||
extensions:transformer.getExtensions() | ||
extensions:transformer.getExtensions(), | ||
verbose:options.verbose | ||
}); | ||
@@ -167,5 +177,28 @@ | ||
function (wfCb) { | ||
if (self.noclean) { | ||
wfCb(); | ||
} else { | ||
// Remove the output directory if it exists | ||
existsCompat(self.outputTo, function (exists) { | ||
if (exists) { | ||
if (self.verbose) { | ||
console.log('compileAssets: removing output directory: ' + self.outputTo); | ||
} | ||
rimraf(self.outputTo, wfCb); | ||
} else { | ||
wfCb(); | ||
} | ||
}); | ||
} | ||
}, | ||
function (wfCb) { | ||
if (self.verbose) { | ||
console.log('compileAssets: starting asset discovery phase.'); | ||
} | ||
executePhase(self.phases.discovery, bundle, wfCb); | ||
}, | ||
function (b, wfCb) { | ||
if (self.verbose) { | ||
console.log('compileAssets: starting compilation phase.'); | ||
} | ||
try { | ||
@@ -186,2 +219,5 @@ // Get the correct order of asset dependencies | ||
}, function (wfCb) { | ||
if (self.verbose) { | ||
console.log('compileAssets: starting post-compilation phase.'); | ||
} | ||
async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { | ||
@@ -191,2 +227,5 @@ executePhase(self.phases.postCompilation, asset, eachCb); | ||
}, function (wfCb) { | ||
if (self.verbose) { | ||
console.log('compileAssets: starting output phase.'); | ||
} | ||
async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { | ||
@@ -207,2 +246,5 @@ executePhase(self.phases.output, asset, eachCb); | ||
compileSingleAsset:function (assetFilePath, cb) { | ||
if (this.verbose) { | ||
console.log('compileSingleAsset: compiling ' + assetFilePath); | ||
} | ||
var self = this; | ||
@@ -263,5 +305,11 @@ // Normalize the path | ||
function (wfCb) { | ||
if (self.verbose) { | ||
console.log('findAssets: starting discovery phase'); | ||
} | ||
executePhase(self.phases.discovery, bundle, wfCb); | ||
}, | ||
function (b, wfCb) { | ||
if (self.verbose) { | ||
console.log('findAssets: starting name transformation phase'); | ||
} | ||
async.eachLimit(bundle.getAllAssets(), 50, function (asset, eachCb) { | ||
@@ -268,0 +316,0 @@ executePhase(self.phases.nameTransformation, asset, eachCb); |
@@ -37,2 +37,3 @@ /** | ||
this.extensions = options.extensions || ['.mf', '.js', '.css']; | ||
this.verbose = options.verbose; | ||
}; | ||
@@ -127,2 +128,5 @@ ManifestWalker.prototype = { | ||
} else { | ||
if (self.verbose && !f) { | ||
console.log('require: file could not be found in any configured asset paths: ' + file); | ||
} | ||
self.registerRequiredAsset(manifest, assetBundle, f, cb); | ||
@@ -167,5 +171,14 @@ } | ||
dirPath = dir; | ||
fs.readdir(dir, wfCb); | ||
existsCompat(dir, function (exists) { | ||
if (exists) { | ||
fs.readdir(dir, wfCb); | ||
} else { | ||
wfCb(null, []); | ||
} | ||
}); | ||
}, | ||
function (files, wfCb) { | ||
if (self.verbose && files.length === 0) { | ||
console.log('require_dir: directory does not exist or contains no assets: ' + dirPath); | ||
} | ||
async.eachSeries(files, function (f, eachCb) { | ||
@@ -187,2 +200,3 @@ setImmediateCompat(function () { | ||
var manifestFilePath = manifest.assetFilePath; | ||
var dirPath; | ||
var self = this; | ||
@@ -194,5 +208,9 @@ async.waterfall([ | ||
function (dir, wfCb) { | ||
dirPath = dir; | ||
glob(path.join(dir, '**/*.*'), wfCb); | ||
}, | ||
function (files, wfCb) { | ||
if (self.verbose && files.length === 0) { | ||
console.log('require_tree: directory does not exist or contains no assets: ' + dirPath); | ||
} | ||
async.eachSeries(files, function (f, eachCb) { | ||
@@ -199,0 +217,0 @@ setImmediateCompat(function () { |
{ | ||
"name": "asset-smasher", | ||
"description": "Asset pre-processor, merger, and compressor.", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"author": "Jim Riecken <jriecken@gmail.com>", | ||
@@ -33,2 +33,3 @@ "keywords": [ | ||
"minimatch": "0.2.11", | ||
"rimraf":"2.1.4", | ||
"send":"0.1.0", | ||
@@ -35,0 +36,0 @@ "uglify-js": "2.2.5", |
@@ -130,2 +130,5 @@ # Asset Smasher | ||
</li> | ||
<li> | ||
If the file does not exist/can't be resolved, it will be ignored (will be logged in verbose mode). | ||
</li> | ||
</ul> | ||
@@ -150,2 +153,5 @@ </td> | ||
</li> | ||
<li> | ||
If the directory does not exist, it will be ignored (will be logged in verbose mode). | ||
</li> | ||
</ul> | ||
@@ -193,4 +199,7 @@ </td> | ||
--plugins <js_file> a .js plugin module [] | ||
--verbose output more verbose information about what is going on to the console | ||
--noclean do not delete the output directory before generating files (by default it will be removed first) | ||
If --only is not specified, *all* files in the --paths will be processed. | ||
If --hash is specified, a map.json file will be generated that maps the unmangled file name to the hashed one. | ||
@@ -207,3 +216,3 @@ Examples: | ||
--paths ./js,./css,./images \ | ||
--only **/*.{jpg,gif,png},application.js.mf,application.css.mf ./public/assets | ||
--only **/*.jpg,**/*.gif,**/*.png,application.js.mf,application.css.mf ./public/assets | ||
@@ -309,2 +318,4 @@ Compile assets, providing some custom helpers to the transformation | ||
You *must* include the middleware **before** the Express routing middleware. Otherwise the asset helper functions will not be available for your view to use. | ||
### Example | ||
@@ -409,3 +420,5 @@ | ||
another: 'helper' | ||
} | ||
}, | ||
verbose:true, | ||
noclean:true | ||
}); | ||
@@ -412,0 +425,0 @@ sm.compileAssets(function(err) { |
Sorry, the diff of this file is not supported yet
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
86856
1988
443
10
5
+ Addedrimraf@2.1.4
+ Addedrimraf@2.1.4(transitive)