Skip to content

Commit

Permalink
fix: updating keploy without terminal
Browse files Browse the repository at this point in the history
Signed-off-by: Ayush Sharma <[email protected]>
  • Loading branch information
ayush3160 committed Oct 3, 2024
1 parent 0633be0 commit 16c6499
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions src/updateKeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,46 +96,22 @@ export async function downloadAndInstallKeployBinary(): Promise<void> {
return new Promise<void>((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
}
});
}


0 comments on commit 16c6499

Please sign in to comment.