Skip to content

Commit

Permalink
Fixed issue where circular dependencies in dependency tree would caus…
Browse files Browse the repository at this point in the history
…e the flatten function to infinitely recurse. If the current key is found to be already in the data object (which means it was already processed), we stop processing that key and return the data object.

Resolves: #22
  • Loading branch information
yzapuchlak committed Nov 25, 2014
1 parent 917193d commit bd549b3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ var flatten = function(options) {
key = json.name + '@' + json.version;
}

// If we have processed this key already, just return the data object.
// This was added so that we don't recurse forever if there was a circular
// dependency in the dependency tree.
if (data[key]) {
return data;
}

data[key] = moduleInfo;

if (json.repository) {
Expand Down

0 comments on commit bd549b3

Please sign in to comment.