Skip to content

Commit

Permalink
Use zsh when runing uv in VirtualEnv for macOS. (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
robinjhuang authored Dec 10, 2024
1 parent a183f46 commit 26b8317
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main-process/comfyDesktopApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getModelsDirectory, validateHardware } from '../utils';
import { DownloadManager } from '../models/DownloadManager';
import { VirtualEnvironment } from '../virtualEnvironment';
import { InstallWizard } from '../install/installWizard';
import { Terminal } from '../terminal';
import { Terminal } from '../shell/terminal';
import { DesktopConfig } from '../store/desktopConfig';
import { InstallationValidator } from '../install/installationValidator';
import { restoreCustomNodes } from '../services/backup';
Expand Down
19 changes: 4 additions & 15 deletions src/terminal.ts → src/shell/terminal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as os from 'node:os';
import * as pty from 'node-pty';
import { AppWindow } from './main-process/appWindow';
import { IPC_CHANNELS } from './constants';
import { AppWindow } from '../main-process/appWindow';
import { IPC_CHANNELS } from '../constants';
import { getDefaultShell } from './util';

export class Terminal {
#pty: pty.IPty | undefined;
Expand Down Expand Up @@ -48,7 +48,7 @@ export class Terminal {
#createPty() {
const window = this.window;
// TODO: does this want to be a setting?
const shell = this.#getDefaultShell();
const shell = getDefaultShell();
const instance = pty.spawn(shell, [], {
handleFlowControl: false,
conptyInheritCursor: false,
Expand All @@ -74,15 +74,4 @@ export class Terminal {

return instance;
}

#getDefaultShell(): string {
switch (os.platform()) {
case 'win32':
return 'powershell.exe';
case 'darwin':
return 'zsh';
default: // Linux and others
return 'bash';
}
}
}
12 changes: 12 additions & 0 deletions src/shell/util.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os from 'os';

export function getDefaultShell(): string {
switch (os.platform()) {
case 'win32':
return 'powershell.exe';
case 'darwin':
return 'zsh';
default: // Linux and others
return 'bash';
}
}
3 changes: 2 additions & 1 deletion src/virtualEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { pathAccessible } from './utils';
import { app } from 'electron';
import * as pty from 'node-pty';
import * as os from 'os';
import { getDefaultShell } from './shell/util';

type ProcessCallbacks = {
onStdout?: (data: string) => void;
Expand All @@ -28,7 +29,7 @@ export class VirtualEnvironment {

get uvPtyInstance() {
if (!this.uvPty) {
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
const shell = getDefaultShell();
this.uvPty = pty.spawn(shell, [], {
handleFlowControl: false,
conptyInheritCursor: false,
Expand Down

0 comments on commit 26b8317

Please sign in to comment.