@travetto/web 7.0.0 → 7.0.1
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/package.json +10 -10
- package/src/util/net.ts +8 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/web",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Declarative support for creating Web Applications",
|
|
6
6
|
"keywords": [
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
"directory": "module/web"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^7.0.
|
|
30
|
-
"@travetto/context": "^7.0.
|
|
31
|
-
"@travetto/di": "^7.0.
|
|
32
|
-
"@travetto/registry": "^7.0.
|
|
33
|
-
"@travetto/runtime": "^7.0.
|
|
34
|
-
"@travetto/schema": "^7.0.
|
|
29
|
+
"@travetto/config": "^7.0.1",
|
|
30
|
+
"@travetto/context": "^7.0.1",
|
|
31
|
+
"@travetto/di": "^7.0.1",
|
|
32
|
+
"@travetto/registry": "^7.0.1",
|
|
33
|
+
"@travetto/runtime": "^7.0.1",
|
|
34
|
+
"@travetto/schema": "^7.0.1",
|
|
35
35
|
"find-my-way": "^9.3.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^7.0.
|
|
39
|
-
"@travetto/test": "^7.0.
|
|
40
|
-
"@travetto/transformer": "^7.0.
|
|
38
|
+
"@travetto/cli": "^7.0.1",
|
|
39
|
+
"@travetto/test": "^7.0.1",
|
|
40
|
+
"@travetto/transformer": "^7.0.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@travetto/transformer": {
|
package/src/util/net.ts
CHANGED
|
@@ -9,7 +9,7 @@ export class NetUtil {
|
|
|
9
9
|
|
|
10
10
|
/** Is an error an address in use error */
|
|
11
11
|
static isPortUsedError(error: unknown): error is Error & { port: number } {
|
|
12
|
-
return !!error && error instanceof Error && error.message.includes('EADDRINUSE');
|
|
12
|
+
return !!error && error instanceof Error && error.message.includes('EADDRINUSE') && 'port' in error && typeof error.port === 'number';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/** Get the port process id */
|
|
@@ -22,14 +22,6 @@ export class NetUtil {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** Free port if in use */
|
|
26
|
-
static async freePort(port: number): Promise<void> {
|
|
27
|
-
const processId = await this.getPortProcessId(port);
|
|
28
|
-
if (processId) {
|
|
29
|
-
process.kill(processId);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
25
|
/** Find free port */
|
|
34
26
|
static async getFreePort(): Promise<number> {
|
|
35
27
|
return new Promise<number>((resolve, reject) => {
|
|
@@ -64,12 +56,13 @@ export class NetUtil {
|
|
|
64
56
|
* @param error The error that may indicate a port conflict
|
|
65
57
|
* @returns Returns true if the port was freed, false if not handled
|
|
66
58
|
*/
|
|
67
|
-
static async freePortOnConflict(error: unknown): Promise<
|
|
68
|
-
if (
|
|
69
|
-
await
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
static async freePortOnConflict(error: unknown): Promise<{ processId?: number, port: number } | undefined> {
|
|
60
|
+
if (this.isPortUsedError(error)) {
|
|
61
|
+
const processId = await this.getPortProcessId(error.port);
|
|
62
|
+
if (processId) {
|
|
63
|
+
process.kill(processId);
|
|
64
|
+
}
|
|
65
|
+
return { port: error.port, processId };
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
68
|
}
|