-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from eiriksm/use-tap-and-coverage-report
Re-factor a bit and report coverage.
- Loading branch information
Showing
6 changed files
with
57 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,5 @@ node_js: | |
- 6 | ||
- 8 | ||
- node | ||
after_script: | ||
- npm run test-cov-report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
test: | ||
node test/test.js | ||
npm test | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
;(function() { | ||
'use strict'; | ||
var os = require('os'); | ||
var util = require('util'); | ||
var ifaces = os.networkInterfaces(); | ||
'use strict'; | ||
var os = require('os'); | ||
var util = require('util'); | ||
var ifaces = os.networkInterfaces(); | ||
|
||
var getLocalIp = function(iface, callback) { | ||
var returnVal; | ||
for (var dev in ifaces) { | ||
if (ifaces.hasOwnProperty(dev)) { | ||
// If the user does not specify anything, last value will be returned. | ||
if (iface && dev !== iface) { | ||
continue; | ||
} | ||
for (var i = 0, len = ifaces[dev].length; i < len; i++) { | ||
var details = ifaces[dev][i]; | ||
if (details.family === 'IPv4') { | ||
returnVal = details.address; | ||
} | ||
} | ||
var getLocalIp = function(iface, callback) { | ||
var returnVal; | ||
Object.keys(ifaces).forEach(function(dev) { | ||
// If the user does not specify anything, last value will be returned. | ||
if (iface && dev !== iface) { | ||
return; | ||
} | ||
for (var i = 0, len = ifaces[dev].length; i < len; i++) { | ||
var details = ifaces[dev][i]; | ||
if (details.family === 'IPv4') { | ||
returnVal = details.address; | ||
} | ||
} | ||
}); | ||
var error = util.format('No address found on %s', iface); | ||
if (!callback) { | ||
if (!returnVal) { | ||
callback(new Error(util.format('No address found on %s', iface))); | ||
return; | ||
throw new Error(error); | ||
} | ||
callback(null, returnVal); | ||
}; | ||
module.exports = getLocalIp; | ||
})(); | ||
|
||
return returnVal; | ||
} | ||
if (!returnVal) { | ||
return callback(new Error(error)); | ||
} | ||
return callback(null, returnVal); | ||
}; | ||
module.exports = getLocalIp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters