Skip to content

Commit 1e4fd2b

Browse files
initial nextKatacodaStep wikirunner
1 parent 6f3f59f commit 1e4fd2b

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

runners/wikiConsole/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RunCommand } from "../../engine/run_command";
33
import { RunResult } from "../../engine/run_result";
44
import { WikiRunner } from "../../engine/wikiRunner";
55
import * as path from "path";
6+
import * as fs from 'fs';
67

78
export class WikiConsole extends WikiRunner {
89

@@ -126,5 +127,26 @@ export class WikiConsole extends WikiRunner {
126127
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "createDevon4jProject.asciidoc"), { name: runCommand.command.parameters[0] });
127128
return null;
128129
}
130+
131+
runNextKatacodaStep(runCommand: RunCommand): RunResult {
132+
let tempFile = path.join(this.getTempDirectory(), runCommand.command.name + ".md");
133+
fs.writeFileSync(tempFile, "");
134+
for(let i = 0; i < runCommand.command.parameters[1].length; i++) {
135+
let param = runCommand.command.parameters[1][i];
136+
if(param.content) {
137+
fs.appendFileSync(tempFile, param.content);
138+
} else if(param.file) {
139+
fs.appendFileSync(tempFile, fs.readFileSync(path.join(this.playbookPath, param.file), "utf-8"));
140+
} else if (param.image) {
141+
let image = path.join(this.playbookPath, param.image);
142+
fs.appendFileSync(tempFile, "![" + path.basename(image) + "](./assets/" + path.basename(image) + ")");
143+
}
144+
fs.appendFileSync(tempFile, "\n\n");
145+
}
146+
147+
let content = fs.readFileSync(tempFile, "utf-8");
148+
this.renderWiki(path.join(this.getRunnerDirectory(), "templates", "nextKatacodaStep.asciidoc"), { title: runCommand.command.parameters[0], content: content, path: runCommand.command.parameters[2]});
149+
return null;
150+
}
129151
}
130152

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
== <%= title; %>
2+
3+
<%= content; %>
4+
5+
<% if(path) {%>
6+
After that, move to the target directory by executing `cd <%= path; %>` in the terminal.
7+
<% } %>

0 commit comments

Comments
 (0)