Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #54 from fb55/master

Handle version numbers with build details properly
  • Loading branch information...
commit e42d54731d1277dfb2e8694fa8f7abf7debc065f 2 parents 4448b3e + a0baaa6
@fb55 fb55 authored
Showing with 11 additions and 2 deletions.
  1. +2 −2 lib/require-analyzer.js
  2. +9 −0 test/require-analyzer-test.js
View
4 lib/require-analyzer.js
@@ -641,7 +641,7 @@ analyzer.extractVersions = function (dependencies) {
var raw = dependencies[pkg] || '*',
parse = semver.expressions.parse.exec(raw.trim()),
version = parse ? parse.slice(1) : raw,
- build = version ? version[4] : null;
+ build = version ? version[3] || version[4] : null;
if (!/^[v\d]+/.test(raw)) {
all[pkg] = raw;
}
@@ -650,7 +650,7 @@ analyzer.extractVersions = function (dependencies) {
}
else {
version[2] = build ? version[2] : 'x';
- all[pkg] = build ? '>= ' + dependencies[pkg].version : version.filter(Boolean).join('.');
+ all[pkg] = build ? '>= ' + dependencies[pkg] : version.filter(Boolean).join('.');
}
});
View
9 test/require-analyzer-test.js
@@ -141,6 +141,15 @@ vows.describe('require-analyzer').addBatch({
"the isNative() method": {
"when passed native package": nativeSubjects,
"when passed non-native package": nonNativeSubjects
+ },
+ "the extractVersions() method": {
+ "when passed a version with a specified build": function(){
+ var result = analyzer.extractVersions({"a": "0.1.2-3", "b": "2.3.4-five"});
+ assert.deepEqual(result, {
+ "a": ">= 0.1.2-3",
+ "b": ">= 2.3.4-five"
+ });
+ }
}
}
}).export(module);
Please sign in to comment.
Something went wrong with that request. Please try again.