Skip to content

Commit

Permalink
resolves issue#12, check non-local remotes when semver not satisfied
Browse files Browse the repository at this point in the history
  • Loading branch information
clintwood (Office) committed Jul 20, 2014
1 parent 33568e8 commit 2dceb3b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/semver.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,28 @@ Resolver.prototype.resolveSemverLocally = function (branch, name, ref) {
*/

Resolver.prototype.resolveSemverRemotely = function* (branch, name, ref) {
var remote = yield* this.remote.resolve(branch.resolvedRemotes, name);
if (!remote) throw new Error('no remote found for dependency "' + name + '".');
var versions = yield* remote.versions(name);
var version = semver.maxSatisfying(versions, ref);
if (version) return version;
var remotes = branch.resolvedRemotes;
// try resolve using resolvedRemotes but
// special case 'local' if unsuccessful
// i.e. if 'ref' is not satisfied by 'local' afford
// non-local resolvedRemotes to try to resolve it
do {
var remote = yield* this.remote.resolve(remotes, name);

This comment has been minimized.

Copy link
@timaschew

timaschew Jan 21, 2015

Member

don't understand the comment and why ref is not passed here to this.remote.resolv()

This comment has been minimized.

Copy link
@clintwood

clintwood Jan 21, 2015

Contributor

@timaschew, If I remember correctly, at this point in the resolving process if the 'locals remote' finds a component of some version (under components) which does not match the specific target version/semver it used to fail and because 'local' is the first resolved remote in branch.resolvedRemotes it didn't look any further. So what this does if not successful on first pass is temporarily remove the 'local remote' so that remotes are forced try resolve again remotely.

As for why the ref is not passed in I can't remember but I think a debugger breakpoint may tell a story...

if (!remote) throw new Error('no remote found for dependency "' + name + '".');
var versions = yield* remote.versions(name);
var version = semver.maxSatisfying(versions, ref);
if (version) return version;
remotes = remotes.filter(nonLocal);
} while (remote.name === 'local');

// no satisfying versions!
// this is an error for semver ranges
if (ref !== '*') throw new Error('invalid semver range "' + ref + '" for "' + name + '"');
// to do: use the actual "main" branch
// ex. gh-pages
return 'master';
}

function nonLocal(remote) {
return (remote !== 'local');
}

0 comments on commit 2dceb3b

Please sign in to comment.