1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.before = void 0;
|
4 | const merge_options_1 = require("./merge-options");
|
5 | const controller_class_visitor_1 = require("./visitors/controller-class.visitor");
|
6 | const model_class_visitor_1 = require("./visitors/model-class.visitor");
|
7 | const modelClassVisitor = new model_class_visitor_1.ModelClassVisitor();
|
8 | const controllerClassVisitor = new controller_class_visitor_1.ControllerClassVisitor();
|
9 | const isFilenameMatched = (patterns, filename) => patterns.some((path) => filename.includes(path));
|
10 | const before = (options, program) => {
|
11 | options = (0, merge_options_1.mergePluginOptions)(options);
|
12 | return (ctx) => {
|
13 | return (sf) => {
|
14 | if (isFilenameMatched(options.dtoFileNameSuffix, sf.fileName)) {
|
15 | return modelClassVisitor.visit(sf, ctx, program, options);
|
16 | }
|
17 | if (isFilenameMatched(options.controllerFileNameSuffix, sf.fileName)) {
|
18 | return controllerClassVisitor.visit(sf, ctx, program, options);
|
19 | }
|
20 | return sf;
|
21 | };
|
22 | };
|
23 | };
|
24 | exports.before = before;
|