Skip to content

Commit 8611be0

Browse files
changed installDevonIde and installCobiGen for console runnder. Added platform support
1 parent ff840c7 commit 8611be0

File tree

2 files changed

+31
-8
lines changed

2 files changed

+31
-8
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum ConsolePlatform {
2+
WINDOWS,
3+
LINUX
4+
}

runners/console/index.ts

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,24 @@ import { RunResult } from "../../engine/run_result";
33
import { Step } from "../../engine/step";
44
import { Command } from "../../engine/command";
55
import { Assertions } from "../../assertions";
6+
import { Playbook } from "../../engine/playbook";
7+
import { ConsolePlatform } from "./consoleInterfaces";
68
import * as path from 'path';
79
import * as child_process from "child_process";
810
import * as fs from "fs";
911

1012
export class Console extends Runner {
1113

14+
private platform: ConsolePlatform;
15+
16+
init(playbook: Playbook): void {
17+
if(process.platform=="win32") {
18+
this.platform = ConsolePlatform.WINDOWS;
19+
} else {
20+
this.platform = ConsolePlatform.LINUX;
21+
}
22+
}
23+
1224
runInstallDevonfwIde(step: Step, command: Command): RunResult {
1325
let result = new RunResult();
1426
result.returnCode = 0;
@@ -23,12 +35,15 @@ export class Console extends Runner {
2335

2436
let installDir = path.join(this.getWorkingDirectory(), "devonfw");
2537
this.createFolder(installDir, true);
26-
this.executeCommandSync("curl -L -o devonfw.tar.gz https://bit.ly/2BCkFa9", installDir, result);
27-
this.executeCommandSync("tar -xf devonfw.tar.gz", installDir, result);
28-
29-
this.executeCommandSync(path.join(installDir, "setup") + " " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), "", result, "yes");
30-
31-
this.executeCommandSync(". ~/.bashrc", installDir, result);
38+
39+
if(this.platform == ConsolePlatform.WINDOWS) {
40+
this.executeCommandSync("powershell.exe Invoke-WebRequest -OutFile devonfw.tar.gz https://bit.ly/2BCkFa9", installDir, result);
41+
this.executeCommandSync("powershell.exe tar -xvzf devonfw.tar.gz", installDir, result);
42+
this.executeCommandSync("powershell.exe ./setup " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, "yes");
43+
} else {
44+
this.executeCommandSync("wget -c https://bit.ly/2BCkFa9 -O - | tar -xz", installDir, result);
45+
this.executeCommandSync("bash setup " + path.join(settingsDir, "settings.git").replace(/\\/g, "/"), installDir, result, "yes");
46+
}
3247

3348
return result;
3449
}
@@ -37,7 +52,11 @@ export class Console extends Runner {
3752
let result = new RunResult();
3853
result.returnCode = 0;
3954

40-
this.executeCommandSync("devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result);
55+
if(this.platform == ConsolePlatform.WINDOWS) {
56+
this.executeCommandSync("devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result);
57+
} else {
58+
this.executeCommandSync("~/.devon/devon cobigen", path.join(this.getWorkingDirectory(), "devonfw"), result);
59+
}
4160
return result;
4261
}
4362

@@ -76,7 +95,7 @@ export class Console extends Runner {
7695
private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) {
7796
if(result.returnCode != 0) return;
7897

79-
let process = child_process.spawnSync("cd " + path.join(directory) + " && " + command, { shell: true, input: input });
98+
let process = child_process.spawnSync(command, { shell: true, cwd: directory, input: input });
8099
if(process.status != 0) {
81100
console.log("Error executing command: " + command + " (exit code: " + process.status + ")");
82101
console.log(process.stderr.toString(), process.stdout.toString());

0 commit comments

Comments
 (0)