From 16c64998359152e0a711b2a860c51686f56ad5e3 Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Thu, 3 Oct 2024 13:29:53 +0530 Subject: [PATCH] fix: updating keploy without terminal Signed-off-by: Ayush Sharma --- src/updateKeploy.ts | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/updateKeploy.ts b/src/updateKeploy.ts index c7592c6..f4f6ebc 100644 --- a/src/updateKeploy.ts +++ b/src/updateKeploy.ts @@ -96,46 +96,22 @@ export async function downloadAndInstallKeployBinary(): Promise { return new Promise((resolve, reject) => { try { - let terminalPath: string; - if (process.platform === 'win32') { - // If on Windows, use the correct path to WSL's Bash shell - terminalPath = 'wsl.exe'; - } else { - terminalPath = '/bin/bash'; - - let currentShell = process.env.SHELL || ''; + const curlCmd = `curl --silent -L https://keploy.io/install.sh -o /tmp/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh -noRoot`; - if (!currentShell) { - currentShell = child_process.execSync('echo $SHELL', { encoding: 'utf8' }).trim(); + child_process.exec(curlCmd, (error, stdout, stderr) => { + if (error) { + console.error(`Error during installation: ${error.message}`); + reject(error); + vscode.window.showErrorMessage('Failed to update Keploy binary: ' + error); + return; } - - terminalPath = currentShell; - } - // Create a new terminal instance with the Bash shell - const terminal = vscode.window.createTerminal({ - name: 'Keploy Terminal', - shellPath: terminalPath, + resolve(); + vscode.window.showInformationMessage('Updated Keploy binary successfully!'); }); - // Show the terminal - terminal.show(); - - const curlCmd = `curl --silent -L https://keploy.io/install.sh -o /tmp/install.sh && chmod +x /tmp/install.sh && /tmp/install.sh -noRoot`; - terminal.sendText(curlCmd); - vscode.window.showInformationMessage('Downloading and updating Keploy binary...'); - // Listen for terminal close event - const disposable = vscode.window.onDidCloseTerminal(eventTerminal => { - console.log('Terminal closed'); - if (eventTerminal === terminal) { - disposable.dispose(); // Dispose the listener - resolve(); - } - }); } catch (error) { reject(error); // Reject the promise if an error occurs during execution } }); } - -