Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Feb 16, 2019
1 parent 1c13c41 commit d0c9226
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 33 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- 10
- 8
- 6
- '10'
- '8'
- '6'
14 changes: 2 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,12 @@
"net",
"gateway"
],
"os": [
"android",
"darwin",
"freebsd",
"linux",
"openbsd",
"sunos",
"win32",
"aix"
],
"dependencies": {
"default-gateway": "^3.1.0",
"ipaddr.js": "^1.9.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
"ava": "^1.2.1",
"xo": "^0.24.0"
}
}
10 changes: 4 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ $ npm install internal-ip
```js
const internalIp = require('internal-ip');

internalIp.v6().then(ip => {
console.log(ip);
(async () => {
console.log(await internalIp.v6());
//=> 'fe80::1'
});

internalIp.v4().then(ip => {
console.log(ip);
console.log(await internalIp.v4());
//=> '10.0.0.79'
});
})();

console.log(internalIp.v6.sync())
//=> 'fe80::1'
Expand Down
20 changes: 10 additions & 10 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import {isIPv4, isIPv6} from 'net';
import test from 'ava';
import m from '.';
import internalIp from '.';

// Travis VMs don't have IPs on their interfaces
// https://docs.travis-ci.com/user/ci-environment/#Networking
const ci = Boolean(process.env.CI);
const isCI = Boolean(process.env.CI);

test('IPv6', async t => {
const ip = await m.v6();
if (ci) {
const ip = await internalIp.v6();
if (isCI) {
t.is(ip, null);
} else {
t.true(isIPv6(ip));
}
});

test('IPv4', async t => {
const ip = await m.v4();
if (ci) {
const ip = await internalIp.v4();
if (isCI) {
t.is(ip, null);
} else {
t.true(isIPv4(ip));
}
});

test('synchronous IPv6', t => {
const ip = m.v6.sync();
if (ci) {
const ip = internalIp.v6.sync();
if (isCI) {
t.is(ip, null);
} else {
t.true(isIPv6(ip));
}
});

test('synchronous IPv4', t => {
const ip = m.v4.sync();
if (ci) {
const ip = internalIp.v4.sync();
if (isCI) {
t.is(ip, null);
} else {
t.true(isIPv4(ip));
Expand Down

0 comments on commit d0c9226

Please sign in to comment.