Skip to content

Commit ad3a4c9

Browse files
authored
Throw error in addV3Client*Require unreachable code path (#325)
1 parent 1f0afee commit ad3a4c9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/transforms/v2-to-v3/modules/addV3ClientDefaultRequire.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ export const addV3ClientDefaultRequire = (
3939
if (v2RequireDeclarator && v2RequireDeclarator.nodes().length > 0) {
4040
v2RequireDeclarator.insertAfter(requireDeclarator);
4141
} else {
42-
// Insert at the top of the file.
43-
source.insertBefore(requireDeclarator);
42+
// Unreachable code, throw error
43+
throw new Error(
44+
"Base Require Declarator not found to insert new Require Declarator.\n" +
45+
"Please report your use case on https://github.com/awslabs/aws-sdk-js-codemod"
46+
);
4447
}
4548
};

src/transforms/v2-to-v3/modules/addV3ClientNamedRequire.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ export const addV3ClientNamedRequire = (
8787
if (v2RequireDeclarator && v2RequireDeclarator.nodes().length > 0) {
8888
v2RequireDeclarator.insertAfter(requireDeclarator);
8989
} else {
90-
// Insert at the top of the file.
91-
source.insertBefore(requireDeclarator);
90+
// Unreachable code, throw error
91+
throw new Error(
92+
"Base Require Declarator not found to insert new Require Declarator.\n" +
93+
"Please report your use case on https://github.com/awslabs/aws-sdk-js-codemod"
94+
);
9295
}
9396
};

0 commit comments

Comments
 (0)