From 13e2579b87dbc44e35a8d284bcc818b3255dbda9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 15 Oct 2019 19:29:31 +0200 Subject: [PATCH 1/2] Update dependencies and require node 8 - default-gateway@5 requires node 8 and brings various minor fixes - ava@2 requires node 8.9.4 - removed module.exports.default as mentioned in the TODO - fixed linting issues --- .travis.yml | 2 +- index.d.ts | 3 --- index.js | 13 +++++++------ package.json | 12 ++++++------ 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ae9d62..f98fed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '12' - '10' - '8' - - '6' diff --git a/index.d.ts b/index.d.ts index 34ffbd4..2dbaf02 100644 --- a/index.d.ts +++ b/index.d.ts @@ -45,9 +45,6 @@ interface v4 { declare const internalIp: { v6: v6; v4: v4; - - // TODO: Remove this for the next major release - default: typeof internalIp; }; export = internalIp; diff --git a/index.js b/index.js index 59d630c..8d3932f 100644 --- a/index.js +++ b/index.js @@ -25,17 +25,20 @@ function findIp(gateway) { return ip; } -function promise(family) { - return defaultGateway[family]().then(result => { +async function promise(family) { + try { + const result = await defaultGateway[family](); return findIp(result.gateway) || null; - }).catch(() => null); + } catch (_) { + return null; + } } function sync(family) { try { const result = defaultGateway[family].sync(); return findIp(result.gateway) || null; - } catch (error) { + } catch (_) { return null; } } @@ -47,5 +50,3 @@ internalIp.v6.sync = () => sync('v6'); internalIp.v4.sync = () => sync('v4'); module.exports = internalIp; -// TODO: Remove this for the next major release -module.exports.default = internalIp; diff --git a/package.json b/package.json index d79f4f2..ea6141a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=6" + "node": ">=8.9.4" }, "scripts": { "test": "xo && ava && tsd" @@ -32,12 +32,12 @@ "gateway" ], "dependencies": { - "default-gateway": "^4.2.0", - "ipaddr.js": "^1.9.0" + "default-gateway": "^5.0.4", + "ipaddr.js": "^1.9.1" }, "devDependencies": { - "ava": "^1.4.1", - "tsd": "^0.7.2", - "xo": "^0.24.0" + "ava": "^2.4.0", + "tsd": "^0.9.0", + "xo": "^0.25.3" } } From 7928833df4b10bfe26e4d3c51b46ea6cb4640bf1 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 16 Oct 2019 01:51:15 +0700 Subject: [PATCH 2/2] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ea6141a..936e6a2 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=8.9.4" + "node": ">=8" }, "scripts": { "test": "xo && ava && tsd"