Skip to content

Commit 8c3e426

Browse files
committed
move chdir to next step
1 parent 66cd16d commit 8c3e426

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

src/converter.ts

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
import { getInput, setFailed } from "@actions/core";
1+
import * as core from "@actions/core";
22
import { exec } from "@actions/exec";
3+
import path from "path";
34

45
/**
56
* Converts the given VS Code theme to a Visual Studio theme.
67
* @param dir
78
*/
8-
export async function convertTheme(dir: string): Promise<void> {
9-
const themeToConvert = getInput("path");
9+
export async function convertTheme(
10+
workDir: string,
11+
themePath: string,
12+
): Promise<void> {
13+
const themeDir = path.resolve(themePath);
14+
core.info(`Converting theme ${themeDir}...`);
1015

1116
try {
12-
exec(`bin\Debug\net6.0\ThemeConverter.exe`, [`-i ${themeToConvert}`]);
17+
// ThemeConverter looks for some files in the same directory as the executable relatively,
18+
// so we have to execute it there and not from the action root
19+
process.chdir(
20+
`${core.toPlatformPath(`${workDir}/ThemeConverter/ThemeConverter/bin/Debug/net6.0`)}`,
21+
);
22+
await exec(`./ThemeConverter -i ${themeDir}`);
1323
} catch (error: any) {
14-
setFailed(`Action failed with error: "${error.message}"`);
24+
core.setFailed(`Action failed with error: "${error.message}"`);
1525
}
1626
}

src/main.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export async function run(): Promise<void> {
1515

1616
// Clone and build ThemeConverter program
1717
await cloneRepository(WORK_DIRECTORY);
18-
await buildProject(WORK_DIRECTORY);
18+
const projectDir = await buildProject(WORK_DIRECTORY);
19+
if (projectDir === undefined) throw new Error();
1920

2021
// Convert theme JSON
2122
const path = core.getInput("path");
@@ -24,6 +25,6 @@ export async function run(): Promise<void> {
2425
core.setOutput("output-vsix", "");
2526
} catch (error) {
2627
// Fail the workflow run if an error occurs
27-
if (error instanceof Error) core.setFailed(error.message);
28+
if (error instanceof Error) core.setFailed(error);
2829
}
2930
}

src/themeConverter.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { exec, } from "@actions/exec";
1+
import { exec } from "@actions/exec";
22
import { toPlatformPath, setFailed, info } from "@actions/core";
33

44
/**
@@ -28,8 +28,9 @@ export async function buildProject(buildDir: string): Promise<void> {
2828
info(`Building ThemeConverter project in "${buildDir}"...`);
2929

3030
try {
31-
process.chdir(`${toPlatformPath(`${buildDir}/ThemeConverter/ThemeConverter/`)}`);
32-
await exec(`dotnet build ThemeConverter.csproj`);
31+
await exec(
32+
`dotnet build ${toPlatformPath(`${buildDir}/ThemeConverter/ThemeConverter/ThemeConverter.csproj`)}`,
33+
);
3334
} catch (error) {
3435
setFailed(`Action failed with error: "${(error as Error).message}"`);
3536
}

0 commit comments

Comments
 (0)