mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
24 lines
703 B
TypeScript
24 lines
703 B
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
import choosePort from '../choosePort';
|
|
import type {HostPortCLIOptions} from '@docusaurus/types';
|
|
import {DEFAULT_PORT} from '@docusaurus/utils';
|
|
|
|
export function getCLIOptionHost(
|
|
hostOption: HostPortCLIOptions['host'],
|
|
): string {
|
|
return hostOption ?? 'localhost';
|
|
}
|
|
|
|
export async function getCLIOptionPort(
|
|
portOption: HostPortCLIOptions['port'],
|
|
host: string,
|
|
): Promise<number | null> {
|
|
const basePort = portOption ? parseInt(portOption, 10) : DEFAULT_PORT;
|
|
return choosePort(host, basePort);
|
|
}
|