Fix #40275 - check enableProposedApi flag for logger API

This commit is contained in:
Rob Lourens
2017-12-15 11:01:31 -08:00
parent 851d231fe9
commit aa6e38762d
2 changed files with 16 additions and 5 deletions

View File

@@ -63,13 +63,21 @@ export interface IExtensionApiFactory {
(extension: IExtensionDescription): typeof vscode;
}
export function checkProposedApiEnabled(extension: IExtensionDescription): void {
if (!extension.enableProposedApi) {
throwProposedApiError(extension);
}
}
function throwProposedApiError(extension: IExtensionDescription): never {
throw new Error(`[${extension.id}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.id}`);
}
function proposedApiFunction<T>(extension: IExtensionDescription, fn: T): T {
if (extension.enableProposedApi) {
return fn;
} else {
return <any>(() => {
throw new Error(`[${extension.id}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.id}`);
});
return <any>throwProposedApiError;
}
}