| 334 | } |
| 335 | |
| 336 | async runCommand( |
| 337 | command: string, |
| 338 | options: TerminalOptions = { reuseTerminal: true }, |
| 339 | ): Promise<void> { |
| 340 | let terminal: vscode.Terminal | undefined; |
| 341 | if (vscode.window.terminals.length && options.reuseTerminal) { |
| 342 | if (options.terminalName) { |
| 343 | terminal = vscode.window.terminals.find( |
| 344 | (t) => t?.name === options.terminalName, |
| 345 | ); |
| 346 | } else { |
| 347 | terminal = vscode.window.activeTerminal ?? vscode.window.terminals[0]; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | if (!terminal) { |
| 352 | terminal = vscode.window.createTerminal(options?.terminalName); |
| 353 | } |
| 354 | terminal.show(); |
| 355 | terminal.sendText(command, false); |
| 356 | } |
| 357 | |
| 358 | async saveFile(fileUri: string): Promise<void> { |
| 359 | await this.ideUtils.saveFile(vscode.Uri.parse(fileUri)); |