Skip to content

Commit

Permalink
Fix eslint errors (#556)
Browse files Browse the repository at this point in the history
* Lint code

* [Refactor] Simplify code
  • Loading branch information
webfiltered authored Dec 24, 2024
1 parent 61ac92e commit 65827b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
32 changes: 16 additions & 16 deletions src/main-process/comfyDesktopApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,31 +207,31 @@ export class ComfyDesktopApp {
this.initializeTerminal(virtualEnvironment);

if (customNodeMigrationError) {
// TODO: Replace with IPC callback to handle i18n (SoC).
new Notification({
title: 'Failed to migrate custom nodes',
body: customNodeMigrationError,
}).show();
}
}

/** @returns `undefined` if successful, or an error `string` on failure. */
async migrateCustomNodes(config: DesktopConfig, virtualEnvironment: VirtualEnvironment, callbacks: ProcessCallbacks) {
const customNodeMigrationPath = config.get('migrateCustomNodesFrom');
let customNodeMigrationError: string | null = null;
if (customNodeMigrationPath) {
log.info('Migrating custom nodes from: ', customNodeMigrationPath);
try {
const cmCli = new CmCli(virtualEnvironment);
await cmCli.restoreCustomNodes(customNodeMigrationPath, callbacks);
} catch (error) {
log.error('Error migrating custom nodes', error);
customNodeMigrationError =
error instanceof Error ? error.message : typeof error === 'string' ? error : 'Error migrating custom nodes.';
} finally {
// Always remove the flag so the user doesnt get stuck here
config.delete('migrateCustomNodesFrom');
}
const fromPath = config.get('migrateCustomNodesFrom');
if (!fromPath) return;

log.info('Migrating custom nodes from:', fromPath);
try {
const cmCli = new CmCli(virtualEnvironment);
await cmCli.restoreCustomNodes(fromPath, callbacks);
} catch (error) {
log.error('Error migrating custom nodes:', error);
// TODO: Replace with IPC callback to handle i18n (SoC).
return error?.toString?.() ?? 'Error migrating custom nodes.';
} finally {
// Always remove the flag so the user doesnt get stuck here
config.delete('migrateCustomNodesFrom');
}
return customNodeMigrationError;
}

static create(appWindow: AppWindow, basePath: string): ComfyDesktopApp {
Expand Down
2 changes: 1 addition & 1 deletion src/services/cmCli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import log from 'electron-log/main';
import path from 'path';
import path from 'node:path';
import { getAppResourcesPath } from '../install/resourcePaths';
import { ProcessCallbacks, VirtualEnvironment } from '../virtualEnvironment';
import { fileSync } from 'tmp';
Expand Down

0 comments on commit 65827b2

Please sign in to comment.