Skip to content

Commit cef55a8

Browse files
authored
Rename import to module/require (#70)
1 parent a72bd0c commit cef55a8

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/transforms/v2-to-v3/utils/getV2ClientNames.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const getV2ClientNames = (
1010
source: Collection<any>,
1111
{ v2DefaultModuleName, v2ClientModuleNames }: GetV2ClientNamesOptions
1212
): Array<string> => {
13-
const v2ClientNamesFromDefaultImport = source
13+
const v2ClientNamesFromDefaultModule = source
1414
.find(j.NewExpression, {
1515
callee: {
1616
type: "MemberExpression",
@@ -23,10 +23,10 @@ export const getV2ClientNames = (
2323
(newExpression) => ((newExpression.callee as MemberExpression).property as Identifier).name
2424
);
2525

26-
// Merge v2ClientNamesFromDefaultImport with v2ClientImportNames with duplicates removed.
27-
return v2ClientNamesFromDefaultImport.concat(
26+
// Merge v2ClientNamesFromDefaultModule with v2ClientModuleNames with duplicates removed.
27+
return v2ClientNamesFromDefaultModule.concat(
2828
v2ClientModuleNames.filter(
29-
(v2ClientImportName) => v2ClientNamesFromDefaultImport.indexOf(v2ClientImportName) < 0
29+
(v2ClientModuleName) => v2ClientNamesFromDefaultModule.indexOf(v2ClientModuleName) < 0
3030
)
3131
);
3232
};

src/transforms/v2-to-v3/utils/removeDefaultRequire.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import { getRequireVariableDeclaration } from "./getRequireVariableDeclaration";
55
export const removeDefaultRequire = (
66
j: JSCodeshift,
77
source: Collection<any>,
8-
defaultImportName: string
8+
defaultRequireName: string
99
) => {
1010
getRequireVariableDeclaration(j, source, "aws-sdk")
1111
.filter(
1212
(nodePath) =>
1313
((nodePath.value.declarations[0] as VariableDeclarator).id as Identifier).name ===
14-
defaultImportName
14+
defaultRequireName
1515
)
1616
.remove();
1717
};

src/transforms/v2-to-v3/utils/removeV2ClientRequire.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export const removeV2ClientRequire = (
77
source: Collection<any>,
88
v2ClientName: string
99
) => {
10-
const importSourceName = `aws-sdk/clients/${v2ClientName.toLowerCase()}`;
11-
getRequireVariableDeclaration(j, source, importSourceName)
10+
const requireLiteralName = `aws-sdk/clients/${v2ClientName.toLowerCase()}`;
11+
getRequireVariableDeclaration(j, source, requireLiteralName)
1212
.filter(
1313
(nodePath) =>
1414
((nodePath.value.declarations[0] as VariableDeclarator).id as Identifier).name ===

src/transforms/v2-to-v3/utils/replaceClientCreation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export const replaceClientCreation = (
1212
source: Collection<any>,
1313
{ v2DefaultModuleName, v2ClientName, v3ClientName }: ReplaceClientCreationOptions
1414
): void => {
15-
// Replace clients created with default import.
15+
// Replace clients created with default module.
1616
source
1717
.find(j.NewExpression, {
1818
callee: {
@@ -26,7 +26,7 @@ export const replaceClientCreation = (
2626
return node;
2727
});
2828

29-
// Replace clients created with client import.
29+
// Replace clients created with client module.
3030
source
3131
.find(j.NewExpression, {
3232
callee: { type: "Identifier", name: v2ClientName },

0 commit comments

Comments
 (0)