1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const denodeify = require("denodeify");
|
4 | const SilentError = require('silent-error');
|
5 | const PortFinder = require('portfinder');
|
6 | const getPort = denodeify(PortFinder.getPort);
|
7 | function checkPort(port, host, basePort = 49152) {
|
8 | PortFinder.basePort = basePort;
|
9 | return getPort({ port, host })
|
10 | .then(foundPort => {
|
11 |
|
12 | if (port !== foundPort && port !== 0) {
|
13 | throw new SilentError(`Port ${port} is already in use. Use '--port' to specify a different port.`);
|
14 | }
|
15 |
|
16 | return foundPort;
|
17 | });
|
18 | }
|
19 | exports.checkPort = checkPort;
|
20 |
|
\ | No newline at end of file |