Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update environment check for Theia compatability #1010

Merged
merged 6 commits into from
Sep 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions __tests__/__unit__/extension.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ async function createGlobalMocks() {
WorkspaceFolder: 3
};
}),
UIKindEnums: jest.fn().mockImplementation(() => {
return {
Desktop: 1,
Web: 2
};
}),
testSession: new imperative.Session({
user: "fake",
password: "fake",
Expand Down Expand Up @@ -227,6 +233,7 @@ async function createGlobalMocks() {
Object.defineProperty(globalMocks.mockImperativeConfig, "instance", { value: globalMocks.mockIcInstance, configurable: true });
Object.defineProperty(globalMocks.mockIcInstance, "cliHome", { get: globalMocks.mockCliHome });
Object.defineProperty(vscode.env, "appName", { value: globalMocks.appName, configurable: true });
Object.defineProperty(vscode, "UIKind", { value: globalMocks.UIKindEnums, configurable: true });
Object.defineProperty(Profiles, "createInstance", {
value: jest.fn(() => globalMocks.testProfileOps)
});
Expand Down Expand Up @@ -360,6 +367,7 @@ describe("Extension Unit Tests", () => {
const globalMocks = await createGlobalMocks();

Object.defineProperty(vscode.env, "appName", { value: "Eclipse Theia" });
Object.defineProperty(vscode.env, "uiKind", { value: vscode.UIKind.Web });
globalMocks.mockExistsSync.mockReset();
globalMocks.mockReaddirSync.mockReset();
globalMocks.mockExistsSync.mockReturnValueOnce(true);
Expand Down
6 changes: 4 additions & 2 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const ACTIVE_CONTEXT = CONTEXT_PREFIX + "Active";
export const UNVERIFIED_CONTEXT = CONTEXT_PREFIX + "Unverified";
export const ICON_STATE_OPEN = "open";
export const ICON_STATE_CLOSED = "closed";
export const THEIA = "Eclipse Theia";
export const VSCODE_APPNAME: string[] = ["Visual Studio Code", "VSCodium"];
export const ROOTPATH = path.join(__dirname, "..", "..");

/**
Expand All @@ -71,7 +71,9 @@ export enum PersistenceSchemaEnum {
export function defineGlobals(tempPath: string | undefined) {
// Set app name
const appName: string = vscode.env.appName;
if (appName && appName === this.THEIA) { this.ISTHEIA = true; }
if (appName && !this.VSCODE_APPNAME.includes(appName) && vscode.env.uiKind === vscode.UIKind.Web) {
this.ISTHEIA = true;
}

// Set temp path & folder paths
tempPath !== "" && tempPath !== undefined ?
Expand Down