UNPKG

aws-sdk-js-codemod

Version:

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

24 lines (23 loc) 901 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceAwsEndpoint = void 0; const replaceAwsEndpoint = (j, source, v2GlobalName) => { const endpointCtr = "Endpoint"; if (v2GlobalName) { source .find(j.NewExpression, { callee: { type: "MemberExpression", object: { type: "Identifier", name: v2GlobalName }, property: { type: "Identifier", name: endpointCtr }, }, }) .replaceWith((newExpression) => j.newExpression(j.identifier("URL"), newExpression.node.arguments)); } source .find(j.NewExpression, { callee: { type: "Identifier", name: endpointCtr }, }) .replaceWith((newExpression) => j.newExpression(j.identifier("URL"), newExpression.node.arguments)); }; exports.replaceAwsEndpoint = replaceAwsEndpoint;