mirror of
https://github.com/oliverschwendener/ueli.git
synced 2024-10-04 01:57:45 +03:00
Compare commits
9 Commits
582b98b379
...
5045393379
Author | SHA1 | Date | |
---|---|---|---|
|
5045393379 | ||
|
8d183c60f6 | ||
|
5b6b36a531 | ||
|
98337a9530 | ||
|
2290f4845a | ||
|
e227333737 | ||
|
9c6729a0d5 | ||
|
044534d853 | ||
|
1f53b9121c |
@ -4,6 +4,11 @@ This extension allows you to open recently edited projects and files in vscode.
|
||||
|
||||
![Example](example.png)
|
||||
|
||||
## Settings
|
||||
|
||||
- Prefix: the prefix that triggers the vscode extension.
|
||||
- Command: The command that the extension will invoke to open vscode and pass it the recent item.
|
||||
|
||||
## About this extension
|
||||
|
||||
Author: [Ethan Conneely](https://github.com/IrishBruse)
|
||||
|
9
package-lock.json
generated
9
package-lock.json
generated
@ -48,7 +48,7 @@
|
||||
"tree-kill": "^1.2.2",
|
||||
"typescript": "^5.5.2",
|
||||
"typescript-eslint": "^8.3.0",
|
||||
"vite": "^5.4.7",
|
||||
"vite": "^5.4.8",
|
||||
"vite-plugin-electron": "^0.28.8",
|
||||
"vite-plugin-electron-renderer": "^0.14.6",
|
||||
"vitest": "^2.1.1"
|
||||
@ -10237,11 +10237,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/vite": {
|
||||
"version": "5.4.7",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.7.tgz",
|
||||
"integrity": "sha512-5l2zxqMEPVENgvzTuBpHer2awaetimj2BGkhBPdnwKbPNOlHsODU+oiazEZzLK7KhAnOrO+XGYJYn4ZlUhDtDQ==",
|
||||
"version": "5.4.8",
|
||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.4.8.tgz",
|
||||
"integrity": "sha512-FqrItQ4DT1NC4zCUqMB4c4AZORMKIa0m8/URVCZ77OZ/QSNeJ54bU1vrFADbDsuwfIPcgknRkmqakQcgnL4GiQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esbuild": "^0.21.3",
|
||||
"postcss": "^8.4.43",
|
||||
|
@ -49,7 +49,7 @@
|
||||
"tree-kill": "^1.2.2",
|
||||
"typescript": "^5.5.2",
|
||||
"typescript-eslint": "^8.3.0",
|
||||
"vite": "^5.4.7",
|
||||
"vite": "^5.4.8",
|
||||
"vite-plugin-electron": "^0.28.8",
|
||||
"vite-plugin-electron-renderer": "^0.14.6",
|
||||
"vitest": "^2.1.1"
|
||||
|
@ -1,32 +1,34 @@
|
||||
import type { Dependencies } from "@Core/Dependencies";
|
||||
import type { DependencyRegistry } from "@Core/DependencyRegistry";
|
||||
import type { EventEmitter } from "@Core/EventEmitter";
|
||||
import type { App } from "electron";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { SingleInstanceLockModule } from "./SingleInstanceLockModule";
|
||||
|
||||
describe(SingleInstanceLockModule, () => {
|
||||
it("should request single instance lock", () => {
|
||||
const requestSingleInstanceLockMock = vi.fn().mockReturnValue(true);
|
||||
const quickMock = vi.fn();
|
||||
it("should register the event listener and event emitter", () => {
|
||||
const on = vi.fn();
|
||||
const app = <App>{
|
||||
on: (event: string, callback: () => void) => on(event, callback),
|
||||
};
|
||||
|
||||
SingleInstanceLockModule.bootstrap(<App>{
|
||||
requestSingleInstanceLock: () => requestSingleInstanceLockMock(),
|
||||
quit: () => quickMock(),
|
||||
});
|
||||
const emitEvent = vi.fn();
|
||||
const eventEmitter = <EventEmitter>{
|
||||
emitEvent: (event: string) => emitEvent(event),
|
||||
};
|
||||
|
||||
expect(requestSingleInstanceLockMock).toHaveBeenCalledOnce();
|
||||
expect(quickMock).not.toHaveBeenCalled();
|
||||
});
|
||||
const dependencyRegistry = <DependencyRegistry<Dependencies>>{
|
||||
get: (key: keyof Dependencies) => {
|
||||
const result = <Dependencies>{
|
||||
App: app,
|
||||
EventEmitter: eventEmitter,
|
||||
};
|
||||
|
||||
it("should quit the application if another instance is already running", () => {
|
||||
const requestSingleInstanceLockMock = vi.fn().mockReturnValue(false);
|
||||
return result[key];
|
||||
},
|
||||
};
|
||||
|
||||
const quickMock = vi.fn();
|
||||
|
||||
SingleInstanceLockModule.bootstrap(<App>{
|
||||
requestSingleInstanceLock: () => requestSingleInstanceLockMock(),
|
||||
quit: () => quickMock(),
|
||||
});
|
||||
|
||||
expect(requestSingleInstanceLockMock).toHaveBeenCalledOnce();
|
||||
expect(quickMock).toHaveBeenCalledOnce();
|
||||
SingleInstanceLockModule.bootstrap(dependencyRegistry);
|
||||
expect(on).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
@ -1,10 +1,13 @@
|
||||
import type { App } from "electron";
|
||||
import type { Dependencies } from "@Core/Dependencies";
|
||||
import type { DependencyRegistry } from "@Core/DependencyRegistry";
|
||||
|
||||
export class SingleInstanceLockModule {
|
||||
public static bootstrap(app: App) {
|
||||
if (!app.requestSingleInstanceLock()) {
|
||||
console.log("Quitting application. Reason: another instance is already running");
|
||||
app.quit();
|
||||
}
|
||||
public static bootstrap(dependencyRegistry: DependencyRegistry<Dependencies>) {
|
||||
const eventEmitter = dependencyRegistry.get("EventEmitter");
|
||||
const app = dependencyRegistry.get("App");
|
||||
|
||||
app.on("second-instance", () => {
|
||||
eventEmitter.emitEvent("hotkeyPressed");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
import * as Electron from "electron";
|
||||
import mitt from "mitt";
|
||||
import { platform } from "os";
|
||||
import * as Core from "./Core";
|
||||
import * as Extensions from "./Extensions";
|
||||
|
||||
(async () => {
|
||||
const main = async () => {
|
||||
await Electron.app.whenReady();
|
||||
|
||||
Core.SingleInstanceLockModule.bootstrap(Electron.app);
|
||||
const mitt = (await import("mitt")).default;
|
||||
const platform = (await import("os")).platform;
|
||||
const Core = await import("./Core");
|
||||
const Extensions = await import("./Extensions");
|
||||
|
||||
Core.DockModule.bootstrap(Electron.app);
|
||||
|
||||
const dependencyRegistry = Core.DependencyRegistryModule.bootstrap();
|
||||
@ -37,6 +37,7 @@ import * as Extensions from "./Extensions";
|
||||
Core.XmlParserModule.bootstrap(dependencyRegistry);
|
||||
Core.EventEmitterModule.bootstrap(dependencyRegistry);
|
||||
Core.EventSubscriberModule.bootstrap(dependencyRegistry);
|
||||
Core.SingleInstanceLockModule.bootstrap(dependencyRegistry);
|
||||
Core.BrowserWindowNotifierModule.bootstrap(dependencyRegistry);
|
||||
Core.DateProviderModule.bootstrap(dependencyRegistry);
|
||||
Core.LoggerModule.bootstrap(dependencyRegistry);
|
||||
@ -77,4 +78,10 @@ import * as Extensions from "./Extensions";
|
||||
await Core.BrowserWindowModule.bootstrap(dependencyRegistry);
|
||||
|
||||
Core.RescanOrchestratorModule.bootstrap(dependencyRegistry);
|
||||
})();
|
||||
};
|
||||
|
||||
if (Electron.app.requestSingleInstanceLock()) {
|
||||
main();
|
||||
} else {
|
||||
Electron.app.exit();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user