Skip to content

Commit

Permalink
Changed method - currentWindowsShell
Browse files Browse the repository at this point in the history
  • Loading branch information
SuparnaSuresh committed Nov 11, 2024
1 parent 955e735 commit 1f768f3
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/liberty/devCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ export async function listAllCommands(): Promise<void> {
});
}


// start dev mode
export async function startDevMode(libProject?: LibertyProject | undefined): Promise<void> {
if (libProject !== undefined) {
console.log(localize("starting.liberty.dev.on", libProject.getLabel()));
let terminal = libProject.getTerminal();
if (terminal === undefined) {
const path = Path.dirname(libProject.getPath());
const terminalType = currentWindowsShell();
//fetch the default terminal details and store it in LibertyProject object
const terminalType = defaultWindowsShell();
libProject.setTerminalType(terminalType);
terminal = libProject.createTerminal(path);
if (terminal !== undefined) {
Expand Down Expand Up @@ -359,7 +359,8 @@ export async function customDevMode(libProject?: LibertyProject | undefined, par
let terminal = libProject.getTerminal();
if (terminal === undefined) {
const path = Path.dirname(libProject.getPath());
const terminalType = currentWindowsShell();
//fetch the default terminal details and store it in LibertyProject object
const terminalType = defaultWindowsShell();
libProject.setTerminalType(terminalType);
terminal = libProject.createTerminal(path);
if (terminal !== undefined) {
Expand Down Expand Up @@ -434,7 +435,8 @@ export async function startContainerDevMode(libProject?: LibertyProject | undefi
let terminal = libProject.getTerminal();
if (terminal === undefined) {
const path = Path.dirname(libProject.getPath());
const terminalType = currentWindowsShell();
//fetch the default terminal details and store it in LibertyProject object
const terminalType = defaultWindowsShell();
libProject.setTerminalType(terminalType);
terminal = libProject.createTerminal(path);
if (terminal !== undefined) {
Expand Down Expand Up @@ -533,13 +535,14 @@ export function deleteTerminal(terminal: vscode.Terminal): void {
}

/**
* Reused from vscode-maven
* Reused from vscode-maven - currentWindowsShell()
* https://github.com/microsoft/vscode-maven/blob/main/src/mavenTerminal.ts
* method to fetch default terminal configured
*/

function currentWindowsShell(): ShellType {
const currentWindowsShellPath: string = vscode.env.shell;
const executable: string = Path.basename(currentWindowsShellPath);
function defaultWindowsShell(): ShellType {
const defaultWindowsShellPath: string = vscode.env.shell;
const executable: string = Path.basename(defaultWindowsShellPath);
switch (executable.toLowerCase()) {
case "cmd.exe":
return ShellType.CMD;
Expand Down

0 comments on commit 1f768f3

Please sign in to comment.