Skip to content

Commit

Permalink
Conditionally add comments for unchanged .promise() APIs (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Apr 12, 2024
1 parent 4812a87 commit b5f1b2e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/shy-dogs-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"aws-sdk-js-codemod": patch
---

Conditionally add comments for unchanged .promise() APIs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const env = {...process.env, ...(this.config.env || {})}
const env = {...process.env, ...this.config.env || {}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const env = {...process.env, ...(this.config.env || {})}
const env = {...process.env, ...this.config.env || {}}
2 changes: 1 addition & 1 deletion src/transforms/v2-to-v3/apis/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from "./addEmptyObjectForUndefined";
export * from "./addNotSupportedClientComments";
export * from "./addPromiseRemovalComments";
export * from "./getClientIdentifiersRecord";
export * from "./getClientWaiterStates";
export * from "./getCommandName";
export * from "./getS3SignedUrlApiNames";
export * from "./getV3ClientWaiterApiName";
export * from "./addPromiseRemovalComments";
export * from "./isS3GetSignedUrlApiUsed";
export * from "./isS3UploadApiUsed";
export * from "./removePromiseCalls";
Expand Down
7 changes: 5 additions & 2 deletions src/transforms/v2-to-v3/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ const transformer = async (file: FileInfo, api: API) => {
const importType = getImportType(j, source);

if (importType === null) {
addPromiseRemovalComments(j, source);
if (file.source.includes(".promise(")) {
addPromiseRemovalComments(j, source);
return source.toSource();
}
// Skip transformation, since no import/require statements found for "aws-sdk" package.
return source.toSource();
return file.source;
}

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

0 comments on commit b5f1b2e

Please sign in to comment.