Skip to content

Commit

Permalink
Fix: Ensure node version was integer
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jun 11, 2016
1 parent 28fbaca commit 7427e0b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions node-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

var match = process.version.match(/v(\d+)\.(\d+)\.(\d+)/);
var nodeVersion = {
major: match[1],
minor: match[2],
patch: match[3],
major: parseInt(match[1], 10),
minor: parseInt(match[2], 10),
patch: parseInt(match[3], 10),
};

module.exports = nodeVersion;
10 changes: 10 additions & 0 deletions test/default-resolution.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ var code = require('code');
var defaultResolution = require('../');
var nodeVersion = require('../node-version');

lab.describe('nodeVersion', function() {

lab.it('has all integers and not strings', function(done) {
code.expect(nodeVersion.major).to.be.a.number();
code.expect(nodeVersion.minor).to.be.a.number();
code.expect(nodeVersion.patch).to.be.a.number();
done();
});
});

lab.describe('defaultResolution', function() {
// Typically I don't unit test helpers, but this reduces the last run tests
var major = nodeVersion.major;
Expand Down

0 comments on commit 7427e0b

Please sign in to comment.