Skip to content

Commit e4f5b8f

Browse files
authored
Move DynamoDB clientName check inside replaceDocClientCreation (#518)
1 parent e0677f0 commit e4f5b8f

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/transforms/v2-to-v3/client-instances/replaceDocClientCreation.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { Collection, JSCodeshift } from "jscodeshift";
22

3+
import { DYNAMODB } from "../config";
34
import { getDocClientNewExpression } from "../utils";
45
import { getDynamoDBForDocClient } from "./getDynamoDBForDocClient";
56

67
export interface ReplaceDocClientCreationOptions {
8+
v2ClientName: string;
79
v2ClientLocalName: string;
810
v2GlobalName?: string;
911
}
1012

1113
export const replaceDocClientCreation = (
1214
j: JSCodeshift,
1315
source: Collection<unknown>,
14-
{ v2ClientLocalName, v2GlobalName }: ReplaceDocClientCreationOptions
16+
{ v2ClientName, v2ClientLocalName, v2GlobalName }: ReplaceDocClientCreationOptions
1517
): void => {
18+
if (v2ClientName !== DYNAMODB) return;
19+
1620
if (v2GlobalName) {
1721
source
1822
.find(j.NewExpression, getDocClientNewExpression({ v2GlobalName }))

src/transforms/v2-to-v3/transformer.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
getClientNamesFromGlobal,
99
getClientNamesRecord,
1010
} from "./client-names";
11-
import { DYNAMODB } from "./config";
1211
import {
1312
addClientModules,
1413
getGlobalNameFromModule,
@@ -65,9 +64,7 @@ const transformer = async (file: FileInfo, api: API) => {
6564
replaceClientCreation(j, source, { v2ClientName, v2ClientLocalName, v2GlobalName });
6665
}
6766

68-
if (v2ClientName === DYNAMODB) {
69-
replaceDocClientCreation(j, source, { v2ClientLocalName, v2GlobalName });
70-
}
67+
replaceDocClientCreation(j, source, v2Options);
7168
}
7269

7370
if (v2GlobalName) {

0 commit comments

Comments
 (0)