npm-git-info
Advanced tools
Comparing version 1.0.0 to 1.0.1
19
index.js
@@ -17,5 +17,22 @@ var proto = { | ||
info.abbreviatedSha = package.gitHead && package.gitHead.slice(0, 10); | ||
info.ref = (package._from || '').split('#')[1]; | ||
var requested = package._requested; | ||
var type = requested && requested.type; | ||
switch (type) { | ||
case 'version': | ||
info.ref = requested.spec; | ||
break; | ||
case 'tag': | ||
info.ref = package.version; | ||
break; | ||
default: | ||
info.ref = (package._from || '').split('#')[1]; | ||
break; | ||
} | ||
return info; | ||
}; |
{ | ||
"name": "npm-git-info", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Retrieves git information from package that installed as NPM package.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -68,2 +68,34 @@ var expect = require('expect.js'); | ||
}); | ||
it('should detect info from NPM installed package with version', function() { | ||
// this tests the result of: npm install ember-data@2.4.0 | ||
var subject = info(fixture('npm-version.json')); | ||
expect(subject).to.eql({ | ||
name: 'ember-data', | ||
version: '2.4.0', | ||
sha: '9f8c40927a5e8a7966c251d99eb26c3f1fb0606e', | ||
abbreviatedSha: '9f8c40927a', | ||
ref: '2.4.0' | ||
}); | ||
expect(subject.isInstalledAsNpmPackage()).to.be(true); | ||
expect(subject.hasVersionInRef()).to.be(true); | ||
}); | ||
it('should detect info from NPM installed package without a version', function() { | ||
// this tests the result of: npm install ember-data | ||
var subject = info(fixture('npm-without-version.json')); | ||
expect(subject).to.eql({ | ||
name: 'ember-data', | ||
version: '2.4.0', | ||
sha: '9f8c40927a5e8a7966c251d99eb26c3f1fb0606e', | ||
abbreviatedSha: '9f8c40927a', | ||
ref: '2.4.0' | ||
}); | ||
expect(subject.isInstalledAsNpmPackage()).to.be(true); | ||
expect(subject.hasVersionInRef()).to.be(true); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48359
13
970