diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index ad3025e5c3c..be336e02113 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -207,46 +207,17 @@ export class WindowsManager extends Disposable implements IWindowsMainService { this.workspacesManager = new WorkspacesManager(workspacesMainService, backupMainService, this); this.lifecycleService.when(LifecycleMainPhase.Ready).then(() => this.registerListeners()); - this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.setupNativeHelpers()); + this.lifecycleService.when(LifecycleMainPhase.AfterWindowOpen).then(() => this.installWindowsMutex()); } - private setupNativeHelpers(): void { + private installWindowsMutex(): void { if (isWindows) { - - // Setup Windows mutex try { const WindowsMutex = (require.__$__nodeRequire('windows-mutex') as typeof import('windows-mutex')).Mutex; const mutex = new WindowsMutex(product.win32MutexName); once(this.lifecycleService.onWillShutdown)(() => mutex.release()); } catch (e) { this.logService.error(e); - - if (!this.environmentService.isBuilt) { - this.showMessageBox({ - title: product.nameLong, - type: 'warning', - message: 'Failed to load windows-mutex!', - detail: e.toString(), - noLink: true - }); - } - } - - // Dev only: Ensure Windows foreground love module is present - if (!this.environmentService.isBuilt) { - try { - require.__$__nodeRequire('windows-foreground-love'); - } catch (e) { - this.logService.error(e); - - this.showMessageBox({ - title: product.nameLong, - type: 'warning', - message: 'Failed to load windows-foreground-love!', - detail: e.toString(), - noLink: true - }); - } } } } diff --git a/src/vs/code/test/electron-main/nativeHelpers.test.ts b/src/vs/code/test/electron-main/nativeHelpers.test.ts new file mode 100644 index 00000000000..ff0f589d511 --- /dev/null +++ b/src/vs/code/test/electron-main/nativeHelpers.test.ts @@ -0,0 +1,28 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as assert from 'assert'; +import { isWindows } from 'vs/base/common/platform'; + +suite('Windows Native Helpers', () => { + test('windows-mutex', async () => { + if (!isWindows) { + return; + } + + const mutex = await import('windows-mutex'); + assert.ok(mutex, 'Unable to load windows-mutex dependency.'); + assert.ok(typeof mutex.isActive === 'function', 'Unable to load windows-mutex dependency.'); + }); + + test('windows-foreground-love', async () => { + if (!isWindows) { + return; + } + + const foregroundLove = await import('windows-foreground-love'); + assert.ok(foregroundLove, 'Unable to load windows-foreground-love dependency.'); + }); +}); \ No newline at end of file