Skip to content

Commit b5f1b2e

Browse files
authored
Conditionally add comments for unchanged .promise() APIs (#860)
1 parent 4812a87 commit b5f1b2e

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

.changeset/shy-dogs-visit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"aws-sdk-js-codemod": patch
3+
---
4+
5+
Conditionally add comments for unchanged .promise() APIs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const env = {...process.env, ...(this.config.env || {})}
1+
const env = {...process.env, ...this.config.env || {}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
const env = {...process.env, ...(this.config.env || {})}
1+
const env = {...process.env, ...this.config.env || {}}

src/transforms/v2-to-v3/apis/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
export * from "./addEmptyObjectForUndefined";
22
export * from "./addNotSupportedClientComments";
3+
export * from "./addPromiseRemovalComments";
34
export * from "./getClientIdentifiersRecord";
45
export * from "./getClientWaiterStates";
56
export * from "./getCommandName";
67
export * from "./getS3SignedUrlApiNames";
78
export * from "./getV3ClientWaiterApiName";
8-
export * from "./addPromiseRemovalComments";
99
export * from "./isS3GetSignedUrlApiUsed";
1010
export * from "./isS3UploadApiUsed";
1111
export * from "./removePromiseCalls";

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ const transformer = async (file: FileInfo, api: API) => {
5151
const importType = getImportType(j, source);
5252

5353
if (importType === null) {
54-
addPromiseRemovalComments(j, source);
54+
if (file.source.includes(".promise(")) {
55+
addPromiseRemovalComments(j, source);
56+
return source.toSource();
57+
}
5558
// Skip transformation, since no import/require statements found for "aws-sdk" package.
56-
return source.toSource();
59+
return file.source;
5760
}
5861

5962
replaceDeepImport(j, source, { fromPath: "aws-sdk/global", toPath: PACKAGE_NAME });

0 commit comments

Comments
 (0)