Fix vscodeUtils make a request on every unit test run
Summary:
When running unit tests, every unit would try to make a graphql request (since promises always kick off immediately, even when not being awaited) and print an error. Fixed that by lazily choosing the preferred whatever it is.
Before:
{F241368814}
After:
(crickets)
Reviewed By: passy
Differential Revision: D22208422
fbshipit-source-id: b290d528d94dbed7ae867e07694d8d4cd85d8376
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f2c39aed55
commit
dd0d957d8b
@@ -10,7 +10,7 @@
|
||||
import {getPreferredEditorUriScheme} from '../fb-stubs/user';
|
||||
import {shell} from 'electron';
|
||||
|
||||
const preferredEditorUriScheme: Promise<string> = getPreferredEditorUriScheme();
|
||||
let preferredEditorUriScheme: string | undefined = undefined;
|
||||
|
||||
export function callVSCode(plugin: string, command: string, params?: string) {
|
||||
getVSCodeUrl(plugin, command, params).then((url) => shell.openExternal(url));
|
||||
@@ -21,7 +21,10 @@ export async function getVSCodeUrl(
|
||||
command: string,
|
||||
params?: string,
|
||||
): Promise<string> {
|
||||
return `${await preferredEditorUriScheme}://${plugin}/${command}${
|
||||
if (preferredEditorUriScheme === undefined) {
|
||||
preferredEditorUriScheme = await getPreferredEditorUriScheme();
|
||||
}
|
||||
return `${preferredEditorUriScheme}://${plugin}/${command}${
|
||||
params == null ? '' : `?${params}`
|
||||
}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user