refactor: shouldRunVsCodeCli

This commit is contained in:
Joe Previte 2021-09-20 15:14:46 -07:00
parent 30ade712bf
commit a673cf2833
No known key found for this signature in database
GPG Key ID: 2C91590C6B742C24
1 changed files with 14 additions and 1 deletions

View File

@ -626,7 +626,20 @@ function bindAddrFromAllSources(...argsConfig: Args[]): Addr {
}
export const shouldRunVsCodeCli = (args: Args): boolean => {
return !!args["list-extensions"] || !!args["install-extension"] || !!args["uninstall-extension"]
// Create new interface with only these keys
// Pick<Args, "list-extensions" | "install-extension" | "uninstall-extension">
// Get the keys of new interface
// keyof ...
// Turn that into an array
// Array<...>
type ExtensionArgs = Array<keyof Pick<Args, "list-extensions" | "install-extension" | "uninstall-extension">>
const extensionRelatedArgs: ExtensionArgs = ["list-extensions", "install-extension", "uninstall-extension"]
const argKeys = Object.keys(args)
// If any of the extensionRelatedArgs are included in args
// then we don't want to run the vscode cli
return extensionRelatedArgs.some((arg) => argKeys.includes(arg))
}
/**