Skip to content

Commit d7e4bcb

Browse files
committed
fix: detect is not a function
1 parent 3cb2c23 commit d7e4bcb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

bin/testhub/utils.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const TESTHUB_CONSTANTS = require("./constants");
55
const testObservabilityHelper = require("../../bin/testObservability/helper/helper");
66
const helper = require("../helpers/helper");
77
const accessibilityHelper = require("../accessibility-automation/helper");
8-
const { detect } = require('detect-port');
8+
const detectPort = require('detect-port');
99

1010

1111
const isUndefined = (value) => value === undefined || value === null;
@@ -195,17 +195,18 @@ exports.logBuildError = (error, product = "") => {
195195
}
196196
};
197197

198-
exports.findAvailablePort = async (preferredPort, maxAttempts = 10) => {
198+
exports.findAvailablePort = async (preferredPort, maxAttempts = 10) => {
199+
const findPort = detectPort.detect || detectPort;
199200
let port = preferredPort;
200201
for (let attempts = 0; attempts < maxAttempts; attempts++) {
201202
try {
202-
const availablePort = await detect(port);
203+
const availablePort = await findPort(port);
203204

204205
if (availablePort === port) {
205206
return port;
206207
} else {
207208
// Double-check suggested port
208-
const verify = await detect(availablePort);
209+
const verify = await findPort(availablePort);
209210
if (verify === availablePort) {
210211
return availablePort;
211212
}

0 commit comments

Comments
 (0)