Skip to content

Commit

Permalink
test(examples): add missing composing task example
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Oct 19, 2023
1 parent 72269cc commit 47cc5fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/docs-examples/examples/composing-tasks/alert-code.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TaskExecutor } from "@golem-sdk/golem-js";
(async () => {
const executor = await TaskExecutor.create({
package: "529f7fdaf1cf46ce3126eb6bbcd3b213c314fe8fe884914f5d1106d4",
yagnaOptions: { apiKey: "try_golem" },
});

const result = await executor.run(async (ctx) => {
const res = await ctx
.beginBatch()
.uploadFile("./worker.mjs", "/golem/input/worker.mjs")
.run("node /golem/input/worker.mjs > /golem/input/output.txt")
.run("cat /golem/input/output.txt")
.downloadFile("/golem/input/output.txt", "./output.txt")
.endStream();

for await (const chunk of res) {
chunk.index == 2 ? console.log(chunk.stdout) : "";
}
});

await executor.end();
})();
1 change: 1 addition & 0 deletions tests/examples/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/single-command.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/single-command.cjs" },
{ "cmd": "ts-node", "path": "examples/docs-examples/examples/composing-tasks/single-command.ts" },
{ "cmd": "ts-node", "path": "examples/docs-examples/examples/composing-tasks/alert-code.mjs" },

{ "cmd": "node", "path": "examples/docs-examples/examples/executing-tasks/before-each.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/executing-tasks/foreach.mjs" },
Expand Down

0 comments on commit 47cc5fa

Please sign in to comment.