@abtnode/util 1.16.52 → 1.16.53-beta-20251009-113612-7a16b6a0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/port.js +9 -3
- package/package.json +6 -6
package/lib/port.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const net = require('net');
|
|
2
2
|
const killProcess = require('fkill');
|
|
3
|
+
const detect = require('detect-port');
|
|
3
4
|
const getPm2ProcessInfo = require('./get-pm2-process-info');
|
|
4
5
|
|
|
5
6
|
const noop = () => {};
|
|
@@ -32,8 +33,12 @@ const killProcessOccupiedPorts = async ({ pm2ProcessId, ports = {}, printError =
|
|
|
32
33
|
);
|
|
33
34
|
};
|
|
34
35
|
|
|
35
|
-
const isPortTaken = (port) =>
|
|
36
|
-
|
|
36
|
+
const isPortTaken = async (port) => {
|
|
37
|
+
const nextPort = await detect(port);
|
|
38
|
+
if (nextPort !== port) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
37
42
|
const tester = net
|
|
38
43
|
.createServer()
|
|
39
44
|
.once('error', (err) => {
|
|
@@ -46,8 +51,9 @@ const isPortTaken = (port) =>
|
|
|
46
51
|
.once('listening', () => {
|
|
47
52
|
tester.once('close', () => resolve(false)).close();
|
|
48
53
|
})
|
|
49
|
-
.listen(port, '
|
|
54
|
+
.listen(port, '::'); // 这里需要注意: 如果不加 host, 在某些时候端口占用了, 还是会返回 false
|
|
50
55
|
});
|
|
56
|
+
};
|
|
51
57
|
|
|
52
58
|
/**
|
|
53
59
|
* @param {{
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.
|
|
6
|
+
"version": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.
|
|
22
|
-
"@abtnode/db-cache": "1.16.
|
|
21
|
+
"@abtnode/constant": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
22
|
+
"@abtnode/db-cache": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
23
23
|
"@arcblock/did": "1.25.6",
|
|
24
24
|
"@arcblock/event-hub": "1.25.6",
|
|
25
25
|
"@arcblock/pm2": "^6.0.12",
|
|
26
|
-
"@blocklet/constant": "1.16.
|
|
26
|
+
"@blocklet/constant": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
27
27
|
"@blocklet/error": "^0.2.5",
|
|
28
|
-
"@blocklet/meta": "1.16.
|
|
28
|
+
"@blocklet/meta": "1.16.53-beta-20251009-113612-7a16b6a0",
|
|
29
29
|
"@blocklet/xss": "^0.2.9",
|
|
30
30
|
"@ocap/client": "1.25.6",
|
|
31
31
|
"@ocap/mcrypto": "1.25.6",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"fs-extra": "^11.2.0",
|
|
92
92
|
"jest": "^29.7.0"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "cb28aceba798cdfe4073bb6df9514c09aa3587ba"
|
|
95
95
|
}
|