Archived
1
0

feat: add tests for bindAddrFromArgs

This commit is contained in:
Joe Previte
2021-09-21 10:41:33 -07:00
parent a673cf2833
commit f84757507b
2 changed files with 135 additions and 6 deletions

View File

@ -594,7 +594,11 @@ interface Addr {
port: number
}
function bindAddrFromArgs(addr: Addr, args: Args): Addr {
/**
* This function creates the bind address
* using the CLI args.
*/
export function bindAddrFromArgs(addr: Addr, args: Args): Addr {
addr = { ...addr }
if (args["bind-addr"]) {
addr = parseBindAddr(args["bind-addr"])
@ -626,13 +630,11 @@ function bindAddrFromAllSources(...argsConfig: Args[]): Addr {
}
export const shouldRunVsCodeCli = (args: Args): boolean => {
// Create new interface with only these keys
// Pick<Args, "list-extensions" | "install-extension" | "uninstall-extension">
// Get the keys of new interface
// keyof ...
// Create new interface with only Arg keys
// keyof Args
// Turn that into an array
// Array<...>
type ExtensionArgs = Array<keyof Pick<Args, "list-extensions" | "install-extension" | "uninstall-extension">>
type ExtensionArgs = Array<keyof Args>
const extensionRelatedArgs: ExtensionArgs = ["list-extensions", "install-extension", "uninstall-extension"]
const argKeys = Object.keys(args)