UNPKG

aws-sdk-js-codemod

Version:

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

28 lines (27 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceAwsConfig = void 0; const getObjectWithUpdatedAwsConfigKeys_1 = require("./getObjectWithUpdatedAwsConfigKeys"); const replaceAwsConfig = (j, source, { v2GlobalName, awsGlobalConfig }) => { if (!v2GlobalName) return; source .find(j.NewExpression, { callee: { type: "MemberExpression", object: { type: "Identifier", name: v2GlobalName }, property: { type: "Identifier", name: "Config" }, }, }) .replaceWith((newExpression) => { const nodeArguments = newExpression.node.arguments; if (nodeArguments.length === 0) { return (0, getObjectWithUpdatedAwsConfigKeys_1.getObjectWithUpdatedAwsConfigKeys)(j, j.objectExpression([]), awsGlobalConfig); } if (nodeArguments.length === 1 && nodeArguments[0].type === "ObjectExpression") { return (0, getObjectWithUpdatedAwsConfigKeys_1.getObjectWithUpdatedAwsConfigKeys)(j, nodeArguments[0], awsGlobalConfig); } return newExpression; }); }; exports.replaceAwsConfig = replaceAwsConfig;