Skip to content

Commit

Permalink
add working-directory option
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Apr 12, 2024
1 parent d72f841 commit 0b7c1c8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 21 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
description: Dagger version to install
required: false
default: 0.11.0
working-directory:
description: Set the current working directory
default: .
outputs:
version:
description: FluentCI CLI version installed
Expand Down
1 change: 1 addition & 0 deletions dist/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ setup({
.map((arg) => arg.trim())
.filter((arg) => arg),
pipeline: action.getInput("pipeline"),
workdir: action.getInput("working-directory"),
})
.then(({ version }) => {
action.setOutput("version", version);
Expand Down
25 changes: 14 additions & 11 deletions dist/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { join } from "node:path";
import * as action from "@actions/core";
import { getExecOutput, exec } from "@actions/exec";
import { installDocker } from "./setup-docker.js";
export default async ({ daggerVersion, wasm, pipeline, args, }) => {
export default async ({ daggerVersion, wasm, pipeline, args, workdir, }) => {
// throw error on unsupported platforms (windows)
if (process.platform === "win32") {
throw new Error("FluentCI is not supported on Windows");
Expand Down Expand Up @@ -37,31 +37,34 @@ export default async ({ daggerVersion, wasm, pipeline, args, }) => {
throw new Error("args is required when using wasm");
}
for (const _args of args) {
await exec("fluentci", [
"run",
"--wasm",
pipeline,
..._args.split(" "),
]);
await exec("fluentci", ["run", "--wasm", pipeline, ..._args.split(" ")], {
cwd: workdir,
});
}
return { version };
}
if (!args.length) {
await exec("fluentci", ["run", pipeline]);
await exec("fluentci", ["run", pipeline], { cwd: workdir });
return { version };
}
for (const _args of args) {
await exec("fluentci", ["run", pipeline, ..._args.split(" ")]);
await exec("fluentci", ["run", pipeline, ..._args.split(" ")], {
cwd: workdir,
});
}
}
if (!pipeline) {
if (args.length) {
for (const _args of args) {
if (wasm) {
await exec("fluentci", ["run", "--wasm", ..._args.split(" ")]);
await exec("fluentci", ["run", "--wasm", ..._args.split(" ")], {
cwd: workdir,
});
}
else {
await exec("fluentci", ["run", ..._args.split(" ")]);
await exec("fluentci", ["run", ..._args.split(" ")], {
cwd: workdir,
});
}
}
return { version };
Expand Down
1 change: 1 addition & 0 deletions src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ setup({
.map((arg) => arg.trim())
.filter((arg) => arg),
pipeline: action.getInput("pipeline"),
workdir: action.getInput("working-directory"),
})
.then(({ version }) => {
action.setOutput("version", version);
Expand Down
28 changes: 18 additions & 10 deletions src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default async ({
wasm,
pipeline,
args,
workdir,
}): Promise<{
version: string;
}> => {
Expand Down Expand Up @@ -52,31 +53,38 @@ export default async ({
throw new Error("args is required when using wasm");
}
for (const _args of args) {
await exec("fluentci", [
"run",
"--wasm",
pipeline,
..._args.split(" "),
]);
await exec(
"fluentci",
["run", "--wasm", pipeline, ..._args.split(" ")],
{
cwd: workdir,
}
);
}
return { version };
}
if (!args.length) {
await exec("fluentci", ["run", pipeline]);
await exec("fluentci", ["run", pipeline], { cwd: workdir });
return { version };
}
for (const _args of args) {
await exec("fluentci", ["run", pipeline, ..._args.split(" ")]);
await exec("fluentci", ["run", pipeline, ..._args.split(" ")], {
cwd: workdir,
});
}
}

if (!pipeline) {
if (args.length) {
for (const _args of args) {
if (wasm) {
await exec("fluentci", ["run", "--wasm", ..._args.split(" ")]);
await exec("fluentci", ["run", "--wasm", ..._args.split(" ")], {
cwd: workdir,
});
} else {
await exec("fluentci", ["run", ..._args.split(" ")]);
await exec("fluentci", ["run", ..._args.split(" ")], {
cwd: workdir,
});
}
}
return { version };
Expand Down

0 comments on commit 0b7c1c8

Please sign in to comment.