UNPKG

aws-sdk-js-codemod

Version:

Collection of codemod scripts that help update AWS SDK for JavaScript APIs

19 lines (18 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceClientCreation = void 0; const utils_1 = require("../utils"); const getNewClientExpression_1 = require("./getNewClientExpression"); // Replace v2 client creation with v3 client creation. const replaceClientCreation = (j, source, { v2ClientName, v2ClientLocalName, v2GlobalName, v3ClientName, awsGlobalConfig, }) => { const clientName = v2ClientName === v2ClientLocalName ? v3ClientName : v2ClientLocalName; source .find(j.NewExpression, (0, utils_1.getClientNewExpressionFromLocalName)(v2ClientLocalName)) .replaceWith((v2ClientNewExpression) => (0, getNewClientExpression_1.getNewClientExpression)(j, clientName, { v2ClientNewExpression, awsGlobalConfig })); if (v2GlobalName) { source .find(j.NewExpression, (0, utils_1.getClientNewExpressionFromGlobalName)(v2GlobalName, v2ClientName)) .replaceWith((v2ClientNewExpression) => (0, getNewClientExpression_1.getNewClientExpression)(j, clientName, { v2ClientNewExpression, awsGlobalConfig })); } }; exports.replaceClientCreation = replaceClientCreation;