Skip to content

Commit

Permalink
fix warnings - remove unused dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: kaibocai <[email protected]>
  • Loading branch information
kaibocai committed Jan 16, 2024
1 parent 50b4b7d commit 6fb6544
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 36 deletions.
100 changes: 69 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
"@types/express": "^4.17.15",
"@types/jest": "^27.0.1",
"@types/node": "^16.9.1",
"@types/readline-sync": "^1.4.8",
"@types/uuid": "^8.3.1",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
Expand All @@ -77,7 +76,6 @@
"prettier": "^2.4.0",
"pretty-quick": "^3.1.3",
"ts-jest": "^27.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.5.5"
},
"repository": {
Expand Down
10 changes: 9 additions & 1 deletion src/workflow/internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,15 @@ import { GrpcEndpoint } from "../../network/GrpcEndpoint";
* @typeparam TOutput - The type of the output for the workflow activity.
*/
export function getFunctionName(fn: TWorkflow | TWorkflowActivity<TInput, TOutput>): string {
return fn.name || fn.toString().match(/function\s*([^(]*)\(/)![1];
if (fn.name) {
return fn.name;
} else {
const match = fn.toString().match(/function\s*([^(]*)\(/);

Check warning on line 36 in src/workflow/internal/index.ts

View check run for this annotation

Codecov / codecov/patch

src/workflow/internal/index.ts#L36

Added line #L36 was not covered by tests
if (match === null) {
throw new Error("Unable to determine function name, try to sepecify the workflow/activity name explicitly.");

Check warning on line 38 in src/workflow/internal/index.ts

View check run for this annotation

Codecov / codecov/patch

src/workflow/internal/index.ts#L38

Added line #L38 was not covered by tests
}
return match[1];

Check warning on line 40 in src/workflow/internal/index.ts

View check run for this annotation

Codecov / codecov/patch

src/workflow/internal/index.ts#L40

Added line #L40 was not covered by tests
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/workflow/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe("Workflow", () => {
expectedCompletionSecond += delay * 1000;
}
expect(expectedCompletionSecond).toBeDefined();
const actualCompletionSecond = state?.lastUpdatedAt?.getTime();
const actualCompletionSecond = state?.lastUpdatedAt?.getTime() ?? 0;
expect(actualCompletionSecond).toBeDefined();

expect(state).toBeDefined();
Expand All @@ -209,7 +209,7 @@ describe("Workflow", () => {
expect(state?.runtimeStatus).toEqual(WorkflowRuntimeStatus.COMPLETED);
expect(state?.createdAt).toBeDefined();
expect(state?.lastUpdatedAt).toBeDefined();
expect(expectedCompletionSecond).toBeLessThanOrEqual(actualCompletionSecond!);
expect(expectedCompletionSecond).toBeLessThanOrEqual(actualCompletionSecond);
}, 31000);

it("should wait for external events with a timeout - true", async () => {
Expand Down

0 comments on commit 6fb6544

Please sign in to comment.