Skip to content

Commit

Permalink
Merge pull request #50 from fluentci-io/fix/wasm-plugin-run
Browse files Browse the repository at this point in the history
fix: automatically run wasm plugin if not a dagger module
  • Loading branch information
tsirysndr authored Jun 23, 2024
2 parents e62f083 + 36982c2 commit 55cf85e
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion src/cmd/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,29 @@ async function run(
const fluentciDir = await Deno.stat(
`${options.workDir || "."}/.fluentci`
);
await Deno.stat(`${options.workDir || "."}/.fluentci/mod.ts`);
if (!fluentciDir.isDirectory) {
displayErrorMessage();
}
} catch (_) {
displayErrorMessage();
}
try {
await Deno.stat(`${options.workDir || "."}/.fluentci/mod.ts`);
} catch (_) {
Deno.env.set("WASM_ENABLED", "1");
await runWasmPlugin(pipeline, jobs, options.workDir as string);
Deno.exit(0);
}
}

if (Deno.env.get("FLUENTCI_PROJECT_ID")) {
if (options.remoteExec) {
try {
await Deno.stat(`${options.workDir || "."}/.fluentci/mod.ts`);
} catch (_) {
await runPipelineRemotely(pipeline, jobs, { ...options, wasm: true });
return;
}
await runPipelineRemotely(pipeline, jobs, options);
return;
}
Expand Down Expand Up @@ -133,6 +145,14 @@ async function run(
return;
}

try {
await Deno.stat(`${options.workDir || "."}/.fluentci/mod.ts`);
} catch (_) {
Deno.env.set("WASM_ENABLED", "1");
await runWasmPlugin(pipeline, jobs, options.workDir as string);
Deno.exit(0);
}

let command = new Deno.Command("deno", {
args: [
"run",
Expand Down Expand Up @@ -275,6 +295,20 @@ async function run(
}
version =
version === "latest" ? data.version || data.default_branch : version;

const status = await fetch(
`https://pkg.fluentci.io/${name}@${version}/import_map.json`
).then((res) => res.status);
if (status == 404) {
if (Deno.env.get("FLUENTCI_PROJECT_ID")) {
await runPipelineRemotely(pipeline, jobs, { ...options, wasm: true });
return;
}
Deno.env.set("WASM_ENABLED", "1");
await runWasmPlugin(pipeline, jobs, options.workDir as string);
Deno.exit(0);
}

let denoModule = [
`--import-map=https://pkg.fluentci.io/${name}@${version}/import_map.json`,
`https://pkg.fluentci.io/${name}@${version}/src/dagger/runner.ts`,
Expand Down

0 comments on commit 55cf85e

Please sign in to comment.