Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions runners/katacoda/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,30 +404,27 @@ export class Katacoda extends Runner {

runExecuteCommand(runCommand: RunCommand) : RunResult {
let terminal = (runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].asynchronous)
? this.getTerminal("executeCommand"+runCommand.stepIndex)
? this.getTerminal("executeCommand" + runCommand.stepIndex)
: undefined;

let filepath;
let changeDir = false;
if(runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].dir){
filepath = runCommand.command.parameters[2].asynchronous
? path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[2].dir).replace(/\\/g, "/")
: runCommand.command.parameters[2].dir;
changeDir = true;
this.currentDir = filepath;
}

let cdCommand: string;
if(runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].dir) {
cdCommand = terminal
? this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[2].dir), terminal.terminalId, terminal.isRunning)
: this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY), runCommand.command.parameters[2].dir));
} else {
cdCommand = this.changeCurrentDir(path.join(this.getVariable(this.WORKSPACE_DIRECTORY)));
}

let bashCommand = {
"name" : runCommand.command.parameters[1],
"changeDir" : changeDir,
"path" : filepath,
"terminalId" : terminal ? terminal.terminalId : 1,
"interrupt" : terminal ? terminal.isRunning : false,
"args": (runCommand.command.parameters.length > 2 && runCommand.command.parameters[2].args) ? runCommand.command.parameters[2].args.join(" ") : undefined
}

this.pushStep(runCommand, "Executing the command "+ runCommand.command.parameters[1] , "step"+ runCommand.stepIndex + ".md");
this.renderTemplate("executeCommand.md", this.outputPathTutorial + "step" + (runCommand.stepIndex) + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, bashCommand: bashCommand});
Comment thread
GuentherJulian marked this conversation as resolved.
this.renderTemplate("executeCommand.md", this.outputPathTutorial + "step" + (runCommand.stepIndex) + ".md", { text: runCommand.text, textAfter: runCommand.textAfter, cdCommand: cdCommand, bashCommand: bashCommand });
return null;
}

Expand Down
16 changes: 8 additions & 8 deletions runners/katacoda/templates/executeCommand.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<%= text; %>

<% if(bashCommand.interrupt){%><% if(bashCommand.changeDir){%>We want to execute the command in a different directory so you have to change your current directory. Some command is already running in terminal <%= bashCommand.terminalId; %> to stop the execution just use this command
`cd <%= bashCommand.path; %> `{{execute T<%= bashCommand.terminalId; %> interrupt}} <% }} else{%>
<% if(bashCommand.changeDir){%>We want to execute the command in a different directory so you have to change your current directory.
With the next command we also open a new terminal, so you have to execute the command twice
`cd <%= bashCommand.path; %> `{{execute T<%= bashCommand.terminalId; %>}}. <% } %><% } %>

<% if(bashCommand.interrupt){ %><% if(bashCommand.changeDir){%>Run <%= bashCommand.name; %> with this bash-command.`<%= bashCommand.name; %> <%= bashCommand.args; %>`{{execute T<%= bashCommand.terminalId; %>}} <% } else{%> Some command is already running in terminal <%= bashCommand.terminalId; %>. Rerun the command to stop and relaunch it automatically. `<%= bashCommand.name; %> <%= bashCommand.args; %>`{{execute T<%= bashCommand.terminalId; %> interrupt }} <%} }else{ %>Run <%= bashCommand.name; %> with this bash-command.
`<%= bashCommand.name; %> <%= bashCommand.args; %>`{{execute T<%= bashCommand.terminalId; %>}} <%} %>
<%= cdCommand; %>

<% if(bashCommand.interrupt) { %>
Some command is already running in terminal <%= bashCommand.terminalId; %>. Rerun the command to stop and relaunch it automatically. `<%= bashCommand.name; %> <%= bashCommand.args; %>`{{execute T<%= bashCommand.terminalId; %> interrupt }}
<% } else { %>
Run `<%= bashCommand.name; %>` with this command.
`<%= bashCommand.name; %> <%= bashCommand.args; %>`{{execute T<%= bashCommand.terminalId; %>}}
<% } %>

<%= textAfter; %>