1 | var hashBundle = require("./hash");
|
2 | var reduce = require("lodash").reduce;
|
3 |
|
4 | // Goes through each bundle and marks it as dirty if it's md5 hash representation
|
5 | // has changed. This is used for rebuilding to prevent writing out bundles
|
6 | // that have not changed.
|
7 | module.exports = function(bundles, data){
|
8 | var bundlesKeyed = data.bundles || {};
|
9 |
|
10 | data.bundles = reduce(bundles, function(result, bundle){
|
11 | var hash;
|
12 | if(bundlesKeyed[bundle.name]) {
|
13 | hash = bundlesKeyed[bundle.name].hash;
|
14 | }
|
15 | bundle.hash = hashBundle(bundle);
|
16 | bundle.isDirty = hash !== bundle.hash;
|
17 |
|
18 | result[bundle.name] = bundle;
|
19 | return result;
|
20 | }, {});
|
21 | };
|