Skip to content

Commit

Permalink
Accept equivalent tar ball paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobq committed Jul 15, 2018
1 parent 58d18ac commit 1ca3d53
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/version-checker.js
Expand Up @@ -25,7 +25,8 @@ VersionChecker.satisfies = function(versionSpecified, versionInstalled) {
}
}
} else if (isTarGz(version) && versionInstalled !== unknownVersion) {
return version === versionInstalled;
const resolve = require('path').resolve;
return resolve(version) === resolve(versionInstalled);
}

if (!semver.validRange(version)) {
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/version-checker-test.js
@@ -1,5 +1,6 @@
'use strict';

var path = require('path');
var assert = require('chai').assert;
var VersionChecker = require('../../lib/version-checker');

Expand Down Expand Up @@ -31,6 +32,12 @@ describe('VersionChecker', function() {
it('when the version specified is git-repo with a non-semver tag', function() {
assert.ok(VersionChecker.satisfies('git://github.com/stefanpenner/ember-cli.git#master','0.1.0'));
});

it('when the version is specified as a path to a tar ball and the installed path is equivalent', function () {
const installed = path.join('.', 'foo.tgz');
const specified = path.resolve('foo.tgz');
assert.ok(VersionChecker.satisfies(installed, specified), `${installed} is equivalent to ${specified}`);
});
});

describe('does not satisfy version', function() {
Expand All @@ -54,5 +61,11 @@ describe('VersionChecker', function() {
it('when the version specified is git-repo with a non-matched version', function() {
assert.notOk(VersionChecker.satisfies('git://github.com/stefanpenner/ember-cli.git#v0.1.0','1.0.0'));
});

it('when the version is specified as a path to a tar ball and the installed path is different', function () {
const installed = path.join('foo', 'bar.tgz');
const specified = path.join('quux', 'bar.tgz');
assert.notOk(VersionChecker.satisfies(installed, specified), `${installed} is not equivalent to ${specified}`);
});
});
});

0 comments on commit 1ca3d53

Please sign in to comment.