Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate an asset map and a rails manifest only once #130

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/asset-rev.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ function AssetRev(inputTree, options) {
this.replaceExtensions = options.replaceExtensions || defaults.replaceExtensions;
this.exclude = exclude;
this.fingerprintAssetMap = options.fingerprintAssetMap || defaults.fingerprintAssetMap;
this.generateAssetMap = options.generateAssetMap;
this.generateRailsManifest = options.generateRailsManifest;
this.assetMapPath = options.assetMapPath || defaults.assetMapPath;
this.railsManifestPath = options.railsManifestPath || defaults.railsManifestPath;
this.prepend = options.prepend || defaults.prepend;
Expand All @@ -29,12 +27,16 @@ function AssetRev(inputTree, options) {
// first pass - excludes replaceable source code
this.exclude = exclude.slice();
this.replaceExtensions.forEach(function(ext) { this.exclude.push('**/*.' + ext); }, this);
this.generateAssetMap = false;
this.generateRailsManifest = false;
var fingerprintTree = Fingerprint(inputTree, this);
var assetRewrite = UseRev(fingerprintTree, this);

// second pass - fingerprints replaceable source code
this.exclude = exclude;
this.onlyHash = this.replaceExtensions;
this.generateAssetMap = options.generateAssetMap;
this.generateRailsManifest = options.generateRailsManifest;
var fingerprintTree2 = Fingerprint(assetRewrite, this);
var assetRewrite2 = UseRev(fingerprintTree2, this);

Expand Down
2 changes: 1 addition & 1 deletion tests/filter-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ describe('broccoli-asset-rev', function() {
);

var mappedFiles = actualFiles.filter(function(name) {
if (-1 !== name.lastIndexOf('assetMap.json')) return true;
if (-1 !== name.lastIndexOf('assetMap.json')) return false;
for (var i = 0; i < extensions.length; ++i) {
if (-1 !== name.lastIndexOf(extensions[i])) {
return fs.statSync(path.join(graph.directory, name)).isFile();
Expand Down