-
Notifications
You must be signed in to change notification settings - Fork 754
/
handleHostOption.ts
35 lines (31 loc) · 1.22 KB
/
handleHostOption.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {BsTempOptions, TransformResult} from "../cli-options";
import {BsErrorLevels, BsErrorTypes} from "../../bin";
export function handleHostOption(incoming: BsTempOptions): TransformResult {
const host: string|null = incoming.get("host");
const listen: string|null = incoming.get("listen");
if (host && listen) {
if (host !== listen) {
return [incoming, [{
errors: [
{
error: new Error("Cannot specify both `host` and `listen` options"),
meta() {
return [
"",
"Tip: Use just the `listen` option *only* if you want to bind only to a particular host.",
]
}
}
],
level: BsErrorLevels.Fatal,
type: BsErrorTypes.HostAndListenIncompatible
}]];
}
// whenever we have have both `host` + `listen` options,
// we remove the 'host' to prevent complication further down the line
return [
incoming.delete('host'),
[]];
}
return [incoming, []];
}