diff --git a/.changeset/shy-dogs-visit.md b/.changeset/shy-dogs-visit.md new file mode 100644 index 000000000..c05aa9aef --- /dev/null +++ b/.changeset/shy-dogs-visit.md @@ -0,0 +1,5 @@ +--- +"aws-sdk-js-codemod": patch +--- + +Conditionally add comments for unchanged .promise() APIs diff --git a/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.input.js b/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.input.js index 9f03b0342..0799d24d9 100644 --- a/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.input.js +++ b/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.input.js @@ -1 +1 @@ -const env = {...process.env, ...(this.config.env || {})} \ No newline at end of file +const env = {...process.env, ...this.config.env || {}} \ No newline at end of file diff --git a/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.output.js b/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.output.js index 9f03b0342..0799d24d9 100644 --- a/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.output.js +++ b/src/transforms/v2-to-v3/__fixtures__/misc/no-formatting.output.js @@ -1 +1 @@ -const env = {...process.env, ...(this.config.env || {})} \ No newline at end of file +const env = {...process.env, ...this.config.env || {}} \ No newline at end of file diff --git a/src/transforms/v2-to-v3/apis/index.ts b/src/transforms/v2-to-v3/apis/index.ts index d1860ac3b..4de897081 100644 --- a/src/transforms/v2-to-v3/apis/index.ts +++ b/src/transforms/v2-to-v3/apis/index.ts @@ -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"; diff --git a/src/transforms/v2-to-v3/transformer.ts b/src/transforms/v2-to-v3/transformer.ts index 900ffa06a..3e9e9f8c7 100644 --- a/src/transforms/v2-to-v3/transformer.ts +++ b/src/transforms/v2-to-v3/transformer.ts @@ -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 });