Skip to content

Commit

Permalink
chore(resolver): Minor improvements in resolver code and tests (#4644)
Browse files Browse the repository at this point in the history
* chore(resolver): Minor improvements in resolver code and tests

**Summary**

This is a follow up to #4484 and #4478 which improves the code
around those areas a bit and removes a now-unnecessary `while`
loop.

**Test plan**

Existing tests should pass.

* Fix logic
  • Loading branch information
BYK authored and arcanis committed Oct 6, 2017
1 parent 633b281 commit 9c2bbca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
4 changes: 2 additions & 2 deletions __tests__/package-request.js
Expand Up @@ -19,8 +19,8 @@ async function prepareRequest(pattern: string, version: string, resolved: string
};
if (parentRequest) {
depRequestPattern.parentRequest = parentRequest;
depRequestPattern.parentNames = parentRequest.parentNames.slice(0);
depRequestPattern.parentNames.push(parentRequest.pattern);
depRequestPattern.parentNames = [...parentRequest.parentNames, parentRequest.pattern];

const lock = parentRequest.getLocked();
privateDepCache[parentRequest.pattern] = {version: lock.version, resolved: lock._remote.resolved};
}
Expand Down
8 changes: 1 addition & 7 deletions src/package-reference.js
Expand Up @@ -66,13 +66,7 @@ export default class PackageReference {
addRequest(request: PackageRequest) {
this.requests.push(request);

let requestLevel = -1;
let currentRequest = request;
while (currentRequest && requestLevel < this.level) {
requestLevel += 1;
currentRequest = currentRequest.parentRequest;
}
this.level = requestLevel;
this.level = Math.min(this.level, request.parentNames.length);
}

prune() {
Expand Down

0 comments on commit 9c2bbca

Please sign in to comment.