Comparing version 0.1.7 to 1.0.0
var devip = require("./lib/dev-ip"); | ||
var ip = devip.getIp(null); | ||
console.log(ip); | ||
var ipCli = devip.getIp("cli"); | ||
var ip = devip(); | ||
console.log(ip); |
@@ -12,5 +12,2 @@ #! /usr/bin/env node | ||
var os = require("os"); | ||
var _ = require("lodash"); | ||
var messages = { | ||
@@ -20,12 +17,12 @@ error: "Couldn't find a suitable IP for you to use. (You're probably offline!)" | ||
exports.getIp = function (env) { | ||
/** | ||
* @returns {Array} | ||
*/ | ||
function getIp() { | ||
var networkInterfaces = os.networkInterfaces(); | ||
var networkInterfaces = require("os").networkInterfaces(); | ||
var matches = []; | ||
var returnValue; | ||
// loop through results and check that it's an IPv4 address & it's not internal | ||
_.each(networkInterfaces, function (_interface) { | ||
_.each(_interface, function (address) { | ||
Object.keys(networkInterfaces).forEach(function (item) { | ||
networkInterfaces[item].forEach(function (address) { | ||
if (address.internal === false && address.family === "IPv4") { | ||
@@ -37,22 +34,14 @@ matches.push(address.address); | ||
if (matches.length) { | ||
return matches; | ||
}; | ||
if (matches.length === 1) { | ||
returnValue = matches[0]; | ||
} else { | ||
returnValue = matches; | ||
} | ||
module.exports = getIp; | ||
return returnValue; | ||
} | ||
if (require.main === module) { | ||
if (env === "cli") { | ||
return messages.error; | ||
var out = getIp(); | ||
if (!out.length) { | ||
return console.log(messages.error); | ||
} | ||
return false; | ||
}; | ||
if (require.main === module) { | ||
console.log(exports.getIp("cli")); | ||
console.log(getIp("cli")); | ||
} |
{ | ||
"name": "dev-ip", | ||
"description": "Find a suitable IP host to view local websites on.", | ||
"version": "0.1.7", | ||
"homepage": "https://github.com/shakyshane/dev-ip", | ||
"author": { | ||
"name": "Shane Osbourne", | ||
"email": "shane.osbourne8@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/shakyshane/dev-ip.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/shakyshane/dev-ip/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/shakyshane/dev-ip/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "lib/dev-ip", | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"test": "gulp" | ||
}, | ||
"dependencies": { | ||
"lodash": "~2.2.1" | ||
}, | ||
"devDependencies": { | ||
"gulp": "~3.4.0", | ||
"gulp-mocha": "~0.4.1", | ||
"gulp-jshint": "~1.4.0", | ||
"chai": "~1.9.0", | ||
"sinon": "~1.8.2" | ||
}, | ||
"keywords": [], | ||
"bin": { | ||
"dev-ip": "lib/dev-ip.js" | ||
"name": "dev-ip", | ||
"description": "Find a suitable IP host to view local websites on.", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/shakyshane/dev-ip", | ||
"author": { | ||
"name": "Shane Osbourne", | ||
"email": "shane.osbourne8@gmail.com" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/shakyshane/dev-ip.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/shakyshane/dev-ip/issues" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/shakyshane/dev-ip/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"main": "lib/dev-ip", | ||
"engines": { | ||
"node": ">= 0.8.0" | ||
}, | ||
"scripts": { | ||
"lint": "jshint lib/*.js test/*.js", | ||
"unit": "mocha", | ||
"test": "npm run lint && npm run unit" | ||
}, | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"mocha": "^2.1.0", | ||
"sinon": "^1.12.2" | ||
}, | ||
"keywords": [], | ||
"bin": { | ||
"dev-ip": "lib/dev-ip.js" | ||
}, | ||
"dependencies": { | ||
"jshint": "^2.5.11" | ||
} | ||
} |
@@ -20,4 +20,4 @@ # dev-ip [![Build Status](https://travis-ci.org/shakyShane/dev-ip.png?branch=master)](https://travis-ci.org/shakyShane/dev-ip) | ||
```javascript | ||
var dev_ip = require('dev-ip'); | ||
dev_ip.getIp(); // "192.168.1.76" or false if nothing found (ie, offline user) | ||
var devip = require('dev-ip'); | ||
devip(); // "192.168.1.76" or false if nothing found (ie, offline user) | ||
``` | ||
@@ -24,0 +24,0 @@ |
@@ -24,3 +24,3 @@ "use strict"; | ||
beforeEach(function () { | ||
result = devIp.getIp(null); | ||
result = devIp(null); | ||
}); | ||
@@ -32,3 +32,3 @@ after(function () { | ||
var expected = match1; | ||
assert.equal(result, expected); | ||
assert.deepEqual(result, [expected]); | ||
}); | ||
@@ -48,3 +48,3 @@ it("should return a string matching the regex", function () { | ||
beforeEach(function () { | ||
result = devIp.getIp(null); | ||
result = devIp(null); | ||
}); | ||
@@ -75,11 +75,7 @@ after(function () { | ||
}); | ||
it("should return false", function () { | ||
var actual = devIp.getIp(null); | ||
assert.isFalse(actual); | ||
it("should return empty array", function () { | ||
var actual = devIp(); | ||
assert.isArray(actual); | ||
assert.equal(actual.length, 0); | ||
}); | ||
it("should return an error message if used on command line", function () { | ||
var actual = devIp.getIp("cli"); | ||
var expected = "Couldn't find a suitable IP for you to use. (You're probably offline!)"; | ||
assert.equal(actual, expected); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3
0
0
8728
13
188
+ Addedjshint@^2.5.11
+ Addedbalanced-match@1.0.2(transitive)
+ Addedbrace-expansion@1.1.11(transitive)
+ Addedcli@1.0.1(transitive)
+ Addedconcat-map@0.0.1(transitive)
+ Addedconsole-browserify@1.1.0(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addeddate-now@0.1.4(transitive)
+ Addeddom-serializer@0.2.2(transitive)
+ Addeddomelementtype@1.3.12.3.0(transitive)
+ Addeddomhandler@2.3.0(transitive)
+ Addeddomutils@1.5.1(transitive)
+ Addedentities@1.0.02.2.0(transitive)
+ Addedexit@0.1.2(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedhtmlparser2@3.8.3(transitive)
+ Addedinflight@1.0.6(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedjshint@2.13.6(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedminimatch@3.0.83.1.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpath-is-absolute@1.0.1(transitive)
+ Addedreadable-stream@1.1.14(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedstrip-json-comments@1.0.4(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removedlodash@~2.2.1
- Removedlodash@2.2.1(transitive)