Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditionally add comments for unchanged .promise() APIs #860

Merged
merged 4 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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