From b1b4805c28a3d21501217c17c9dac0519b2301a1 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sun, 17 Oct 2021 00:25:12 +0700 Subject: [PATCH] Require Node.js 12.20 --- .gitattributes | 3 +-- .github/workflows/main.yml | 8 ++------ cli.js | 30 +++++++++++++++++------------- license | 2 +- package.json | 18 ++++++++++-------- readme.md | 14 +++----------- test.js | 2 +- 7 files changed, 35 insertions(+), 42 deletions(-) diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b85fc2a..441975c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,14 +10,10 @@ jobs: fail-fast: false matrix: node-version: - - 14 - - 12 - - 10 - - 8 - - 6 + - 16 steps: - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/cli.js b/cli.js index 01c752b..6f281ad 100755 --- a/cli.js +++ b/cli.js @@ -1,7 +1,6 @@ #!/usr/bin/env node -'use strict'; -const meow = require('meow'); -const internalIp = require('internal-ip'); +import meow from 'meow'; +import {internalIpV6Sync, internalIpV4Sync} from 'internal-ip'; const cli = meow(` Usage @@ -17,15 +16,20 @@ const cli = meow(` $ internal-ip --ipv4 10.0.0.79 `, { - boolean: [ - 'ipv6', - 'ipv4' - ], - alias: { - 6: 'ipv6', - 4: 'ipv4' - } + importMeta: import.meta, + flags: { + ipv6: { + type: 'boolean', + default: true, + alias: '6', + }, + ipv4: { + type: 'boolean', + alias: '4', + }, + }, }); -const fn = cli.flags.ipv4 ? 'v4' : 'v6'; -internalIp[fn]().then(console.log); +const getIp = cli.flags.ipv4 ? internalIpV4Sync : internalIpV6Sync; + +console.log(getIp()); diff --git a/license b/license index e7af2f7..fa7ceba 100644 --- a/license +++ b/license @@ -1,6 +1,6 @@ MIT License -Copyright (c) Sindre Sorhus (sindresorhus.com) +Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/package.json b/package.json index d5c9724..7e9e4af 100644 --- a/package.json +++ b/package.json @@ -4,16 +4,18 @@ "description": "Get your internal IP address", "license": "MIT", "repository": "sindresorhus/internal-ip-cli", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "https://sindresorhus.com" }, + "type": "module", "bin": { - "internal-ip": "cli.js" + "internal-ip": "./cli.js" }, "engines": { - "node": ">=6" + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "scripts": { "test": "xo && ava" @@ -36,12 +38,12 @@ "gateway" ], "dependencies": { - "internal-ip": "^2.0.0", - "meow": "^3.7.0" + "internal-ip": "^7.0.0", + "meow": "^10.1.1" }, "devDependencies": { - "ava": "*", - "execa": "^0.7.0", - "xo": "*" + "ava": "^3.15.0", + "execa": "^5.1.1", + "xo": "^0.45.0" } } diff --git a/readme.md b/readme.md index 119b9b7..421a81c 100644 --- a/readme.md +++ b/readme.md @@ -2,14 +2,12 @@ > Get your internal IP address - ## Install -``` -$ npm install --global internal-ip-cli +```sh +npm install --global internal-ip-cli ``` - ## Usage ``` @@ -29,13 +27,7 @@ $ internal-ip --help 10.0.0.79 ``` - ## Related -- [internal-ip](https://github.com/sindresorhus/internal-ip) - API for this module +- [internal-ip](https://github.com/sindresorhus/internal-ip) - API for this package - [public-ip-cli](https://github.com/sindresorhus/public-ip-cli) - Get your public IP address - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index 244c5b9..ed1d932 100644 --- a/test.js +++ b/test.js @@ -1,4 +1,4 @@ -import {isIPv4, isIPv6} from 'net'; +import {isIPv4, isIPv6} from 'node:net'; import test from 'ava'; import execa from 'execa';