vscode integration helper

Summary: VSCode integration helpers to call extensions

Reviewed By: passy

Differential Revision: D21641284

fbshipit-source-id: dd978520ea541dbd6a96b8398ce28744a0fc97ad
This commit is contained in:
Timur Valiev
2020-05-26 05:00:30 -07:00
committed by Facebook GitHub Bot
parent 0da766f27b
commit 2283bbd313
3 changed files with 32 additions and 0 deletions

View File

@@ -79,3 +79,7 @@ export async function getFlipperMediaCDN(
): Promise<string> {
throw new Error('Feature not implemented');
}
export async function getPreferredEditorUriScheme(): Promise<string> {
return 'vscode';
}

View File

@@ -183,3 +183,4 @@ export {KeyboardActions} from './MenuBar';
export {getFlipperMediaCDN} from './fb-stubs/user';
export {Rect} from './utils/geometry';
export {Logger} from './fb-interfaces/Logger';
export {callVSCode, getVSCodeUrl} from './utils/vscodeUtils';

View File

@@ -0,0 +1,27 @@
/**
* 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.
*
* @format
*/
import {getPreferredEditorUriScheme} from '../fb-stubs/user';
import {shell} from 'electron';
const preferredEditorUriScheme: Promise<string> = getPreferredEditorUriScheme();
export function callVSCode(plugin: string, command: string, params?: string) {
getVSCodeUrl(plugin, command, params).then((url) => shell.openExternal(url));
}
export async function getVSCodeUrl(
plugin: string,
command: string,
params?: string,
): Promise<string> {
return `${await preferredEditorUriScheme}://${plugin}/${command}${
params == null ? '' : `?${params}`
}`;
}