Skip to content

Commit 56efeb3

Browse files
committed
fix: Remove unnecessary dependency @types/bluebird (also removed bluebird internally)
1 parent 98530cd commit 56efeb3

File tree

3 files changed

+12
-40
lines changed

3 files changed

+12
-40
lines changed

package-lock.json

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@
9696
},
9797
"dependencies": {
9898
"@pact-foundation/pact-core": "^13.13.0",
99-
"@types/bluebird": "^3.5.20",
10099
"@types/express": "^4.17.11",
101100
"axios": "^0.27.2",
102-
"bluebird": "~3.5.1",
103101
"body-parser": "^1.20.0",
104102
"cli-color": "^2.0.1",
105103
"express": "^4.18.1",

src/common/net.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import * as net from 'net';
8-
import { Promise as bluebird } from 'bluebird';
98

109
export const localAddresses = ['127.0.0.1', 'localhost', '0.0.0.0', '::1'];
1110

@@ -27,28 +26,19 @@ export const portCheck = (port: number, host: string): Promise<void> =>
2726
});
2827

2928
export const isPortAvailable = (port: number, host: string): Promise<void> =>
30-
Promise.resolve(
31-
bluebird
32-
.map(
33-
localAddresses,
34-
// we meed to wrap the built-in Promise with bluebird.reflect() so we can
35-
// test the result of the promise without failing bluebird.map()
36-
(h) => bluebird.resolve(portCheck(port, h)).reflect(),
37-
// do each port check sequentially (as localhost & 127.0.0.1 will conflict on most default environments)
38-
{ concurrency: 1 }
39-
)
40-
.then((inspections) => {
41-
// if every port check failed, then fail the `isPortAvailable` check
42-
if (inspections.every((inspection) => !inspection.isFulfilled())) {
43-
return Promise.reject(
44-
new Error(`Cannot open port ${port} on ipv4 or ipv6 interfaces`)
45-
);
46-
}
29+
Promise.allSettled(
30+
localAddresses.map((localHost) => portCheck(port, localHost))
31+
).then((settledPortChecks) => {
32+
// if every port check failed, then fail the `isPortAvailable` check
33+
if (settledPortChecks.every((result) => result.status === 'rejected')) {
34+
return Promise.reject(
35+
new Error(`Cannot open port ${port} on ipv4 or ipv6 interfaces`)
36+
);
37+
}
4738

48-
// the local addresses passed - now check the host that the user has specified
49-
return portCheck(port, host);
50-
})
51-
);
39+
// the local addresses passed - now check the host that the user has specified
40+
return portCheck(port, host);
41+
});
5242

5343
export const freePort = (): Promise<number> => {
5444
return new Promise((res) => {

0 commit comments

Comments
 (0)