Update network-manager to v1

Change-type: patch
This commit is contained in:
Felipe Lalanne 2025-01-23 23:40:52 -03:00
parent 25e46574ab
commit f71f98777c
No known key found for this signature in database
GPG Key ID: 03E696BFD472B26A
3 changed files with 16 additions and 21 deletions

17
package-lock.json generated

@ -79,7 +79,7 @@
"mocha": "^10.4.0",
"mocha-pod": "^2.0.5",
"morgan": "^1.10.0",
"network-checker": "^0.1.1",
"network-checker": "^1.0.2",
"nock": "^13.5.6",
"node-loader": "^2.1.0",
"nodemon": "^3.1.9",
@ -10456,15 +10456,14 @@
"dev": true
},
"node_modules/network-checker": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/network-checker/-/network-checker-0.1.1.tgz",
"integrity": "sha512-dc/LiwC0pp37njpe8TA+oRa5BWkH8+WyFVY0aeuDZqMLHq4kaLHqWJowEfKBI7KT39vmTapWJN0SoHxhx6aL4A==",
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/network-checker/-/network-checker-1.0.2.tgz",
"integrity": "sha512-OSMZYdHJ2d6nYUCrUlRT1AT50KyYUTMwFr+K+PWA9pMISElVnHnv3fx/EOYBqTxaaUXskGySCsL4qSz3Qi7D5A==",
"dev": true,
"dependencies": {
"bluebird": "^3.0.0",
"lodash": "^4.0.0",
"request": "^2.51.0"
"license": "ISC",
"engines": {
"node": ">=20",
"npm": ">=10"
}
},
"node_modules/next-tick": {

@ -105,7 +105,7 @@
"mocha": "^10.4.0",
"mocha-pod": "^2.0.5",
"morgan": "^1.10.0",
"network-checker": "^0.1.1",
"network-checker": "^1.0.2",
"nock": "^13.5.6",
"node-loader": "^2.1.0",
"nodemon": "^3.1.9",

@ -1,6 +1,7 @@
import _ from 'lodash';
import { promises as fs, watch } from 'fs';
import networkCheck from 'network-checker';
import { checkHost as checkNetHost, monitor } from 'network-checker';
import type { ConnectOptions, MonitorChangeFunction } from 'network-checker';
import os from 'os';
import url from 'url';
@ -20,21 +21,16 @@ const networkPattern = {
let isConnectivityCheckPaused = false;
let isConnectivityCheckEnabled = true;
function checkHost(
opts: networkCheck.ConnectOptions,
): boolean | PromiseLike<boolean> {
async function checkHost(opts: ConnectOptions): Promise<boolean> {
return (
!isConnectivityCheckEnabled ||
isConnectivityCheckPaused ||
networkCheck.checkHost(opts)
(await checkNetHost(opts))
);
}
function customMonitor(
options: networkCheck.ConnectOptions,
fn: networkCheck.MonitorChangeFunction,
) {
return networkCheck.monitor(checkHost, options, fn);
function customMonitor(options: ConnectOptions, fn: MonitorChangeFunction) {
return monitor(checkHost, options, fn);
}
export function enableCheck(enable: boolean) {
@ -60,7 +56,7 @@ export const startConnectivityCheck = _.once(
async (
apiEndpoint: string,
enable: boolean,
onChangeCallback?: networkCheck.MonitorChangeFunction,
onChangeCallback?: MonitorChangeFunction,
) => {
enableConnectivityCheck(enable);
if (!apiEndpoint) {