Skip to content

Commit 8ec9aa7

Browse files
Mark Lagendijks0ph1e
authored andcommitted
Recursion bug fix (#68)
* Fixed bug with cyclic references. * Fixed jshint issues.
1 parent defaa98 commit 8ec9aa7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/utils.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ function waitAllFulfilled (promises) {
4242
}));
4343
}
4444

45-
function createOutputObject (resource) {
46-
var assets = _(resource.getChildren())
47-
.map(createOutputObject)
48-
.uniq()
49-
.value();
45+
function createOutputObject (resource, outputObjectsByUrl) {
46+
outputObjectsByUrl = outputObjectsByUrl || {};
5047

51-
return {
48+
var outputObject = {
5249
url: resource.getUrl(),
53-
filename: resource.getFilename(),
54-
assets: assets
50+
filename: resource.getFilename()
5551
};
52+
outputObjectsByUrl[outputObject.url] = outputObject;
53+
54+
outputObject.assets = _.map(resource.getChildren(), function getOrCreateChildOutputObject (childResource){
55+
return outputObjectsByUrl[childResource.getUrl()] || createOutputObject(childResource, outputObjectsByUrl);
56+
});
57+
58+
return outputObject;
5659
}
5760

5861
module.exports = {

0 commit comments

Comments
 (0)