Initial upload with CI/CD workflow
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-05 19:31:49 +00:00
parent 2aec2b93d9
commit 449631f055

69
src/utils/osUtils.ts Normal file
View File

@@ -0,0 +1,69 @@
import * as os from 'os';
import * as path from 'path';
import { TerminalType } from '../models/types';
export class OSUtils {
getPlatform(): NodeJS.Platform {
return process.platform;
}
isMacOS(): boolean {
return process.platform === 'darwin';
}
isLinux(): boolean {
return process.platform === 'linux';
}
isWindows(): boolean {
return process.platform === 'win32';
}
getHomeDir(): string {
return os.homedir();
}
getTmpDir(): string {
return os.tmpdir();
}
detectTerminalType(): TerminalType {
if (this.isMacOS()) {
return 'iterm2';
}
return 'tmux';
}
getDefaultShell(): string {
return process.env.SHELL || '/bin/bash';
}
expandPath(filePath: string): string {
if (filePath.startsWith('~')) {
return path.join(this.getHomeDir(), filePath.slice(1));
}
return filePath;
}
getTmuxPath(): string {
return this.isMacOS() ? '/usr/local/bin/tmux' : '/usr/bin/tmux';
}
getScreenPath(): string {
return this.isMacOS() ? '/usr/local/bin/screen' : '/usr/bin/screen';
}
async getCurrentCwd(): Promise<string> {
return process.cwd();
}
getEnv(key: string, defaultValue?: string): string | undefined {
return process.env[key] || defaultValue;
}
setEnv(key: string, value: string): void {
process.env[key] = value;
}
}
export const osUtils = new OSUtils();