Skip to content

Commit 97ed73f

Browse files
committed
refactor(@angular-devkit/build-angular): error handling
1 parent cc466c4 commit 97ed73f

File tree

1 file changed

+2
-4
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/utilities

1 file changed

+2
-4
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/utilities/check-port.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
const net = require('net');
8+
import * as net from 'net';
99

1010
export function checkPort(port: number, host: string, basePort = 49152): Promise<number> {
1111
return new Promise<number>((resolve, reject) => {
@@ -19,9 +19,7 @@ export function checkPort(port: number, host: string, basePort = 49152): Promise
1919
server.once('error', err => {
2020
if (port !== 0 && err.code === 'EADDRINUSE') {
2121
// If the port isn't available and we weren't looking for any port, throw error.
22-
reject(`Port ${port} is already in use. Use '--port' to specify a different port.`);
23-
} else if (port === 0) {
24-
reject(err);
22+
reject(new Error(`Port ${port} is already in use. Use '--port' to specify a different port.`));
2523
}
2624

2725
_getPort(portNumber + 1);

0 commit comments

Comments
 (0)