Determine the right working directory: workspace folder if available, else file's dir, else home.
()
| 66 | |
| 67 | /** Determine the right working directory: workspace folder if available, else file's dir, else home. */ |
| 68 | function getCwd(): string { |
| 69 | const folders = vscode.workspace.workspaceFolders; |
| 70 | if (folders && folders.length > 0) return folders[0].uri.fsPath; |
| 71 | const activeFile = vscode.window.activeTextEditor?.document?.uri?.fsPath; |
| 72 | if (activeFile) return path.dirname(activeFile); |
| 73 | // CRITICAL: fall back to home, NOT process.cwd(). |
| 74 | // process.cwd() in the VS Code extension host is often '/' when VS Code was |
| 75 | // launched from Spotlight / dock / Applications folder — running QodeX from |
| 76 | // '/' breaks ~/.qodex resolution and is generally useless. Home is always sane. |
| 77 | return os.homedir(); |
| 78 | } |
| 79 | |
| 80 | /** Quote a shell string for bash / zsh. */ |
| 81 | function shellQuote(s: string): string { |
no outgoing calls
no test coverage detected