UNPKG

@wroud/di-tools-codemod

Version:

@wroud/di-tools-codemod is a codemod utility that automates the migration of your codebase from Inversify to @wroud/di. It streamlines the transformation process, allowing for effortless and customizable transitions through configuration support.

17 lines (16 loc) 681 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createInjectableDecorator = createInjectableDecorator; const constants_js_1 = require("./constants.js"); function createInjectableDecorator(j, dependencies) { const arrayExpression = j.arrayExpression(dependencies.map((dep) => { if (dep.multiple) { return j.arrayExpression([dep.type]); } return dep.type; })); const newCallExpression = j.callExpression(j.identifier(constants_js_1.CONSTANTS.injectable), dependencies.length > 0 ? [j.arrowFunctionExpression([], arrayExpression)] : []); return j.decorator(newCallExpression); }