aws-sdk-js-codemod
Version:
Collection of codemod scripts that help update AWS SDK for JavaScript APIs
27 lines (26 loc) • 1.27 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNewExpressionCount = void 0;
const config_1 = require("../config");
const utils_1 = require("../utils");
const getNewExpressionCount = (j, source, options) => {
const { v2ClientName, v2ClientLocalName, v2GlobalName } = options;
let newExpressionCount = 0;
if (v2GlobalName) {
const newExpressionsFromGlobalName = source.find(j.NewExpression, (0, utils_1.getClientNewExpressionFromGlobalName)(v2GlobalName, v2ClientName));
newExpressionCount += newExpressionsFromGlobalName.length;
}
const newExpressionsFromClientLocalName = source.find(j.NewExpression, (0, utils_1.getClientNewExpressionFromLocalName)(v2ClientLocalName));
newExpressionCount += newExpressionsFromClientLocalName.length;
if (v2ClientName === config_1.DYNAMODB) {
newExpressionCount += (0, exports.getNewExpressionCount)(j, source, {
...options,
v2ClientName: config_1.DYNAMODB_DOCUMENT_CLIENT,
...(v2ClientLocalName && {
v2ClientLocalName: `${v2ClientLocalName}.${config_1.DOCUMENT_CLIENT}`,
}),
});
}
return newExpressionCount;
};
exports.getNewExpressionCount = getNewExpressionCount;
;