@blaxel/core 0.2.2-dev.59 → 0.2.2-dev.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@ declare class BlJob {
2
2
  getArguments(): Promise<{
3
3
  [key: number]: any;
4
4
  }>;
5
+ private parseCommandLineArgs;
5
6
  get indexKey(): string;
6
7
  get index(): number;
7
8
  start(func: (args: any) => Promise<void>): Promise<void>;
package/dist/jobs/jobs.js CHANGED
@@ -1,21 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.blJob = void 0;
4
- // import yargs from 'yargs';
5
4
  const env_js_1 = require("../common/env.js");
6
5
  class BlJob {
7
6
  async getArguments() {
8
7
  if (!env_js_1.env.BL_EXECUTION_DATA_URL) {
9
- throw new Error('BL_EXECUTION_DATA_URL is not set');
8
+ const args = this.parseCommandLineArgs();
9
+ return args;
10
10
  }
11
- // const argv = await yargs(hideBin(process.argv))
12
- // .parseAsync();
13
- // return argv;
14
- // }
15
11
  const response = await fetch(env_js_1.env.BL_EXECUTION_DATA_URL);
16
12
  const data = await response.json();
17
13
  return data.tasks[this.index] ?? {};
18
14
  }
15
+ parseCommandLineArgs() {
16
+ const args = process.argv.slice(2);
17
+ const result = {};
18
+ for (let i = 0; i < args.length; i++) {
19
+ const arg = args[i];
20
+ if (arg.startsWith('--')) {
21
+ const key = arg.slice(2);
22
+ const value = args[i + 1];
23
+ if (value && !value.startsWith('--')) {
24
+ result[key] = value;
25
+ i++;
26
+ }
27
+ else {
28
+ result[key] = 'true';
29
+ }
30
+ }
31
+ }
32
+ return result;
33
+ }
19
34
  get indexKey() {
20
35
  return env_js_1.env.BL_TASK_KEY ?? "TASK_INDEX";
21
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/core",
3
- "version": "0.2.2-dev.59",
3
+ "version": "0.2.2-dev.60",
4
4
  "description": "Blaxel Core SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",