@taiga-ui/cdk
Version:
Base library for creating Angular components and applications using Taiga UI principles regarding of actual visual appearance
20 lines • 990 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.addCommentForStylesFiles = addCommentForStylesFiles;
const ng_morph_1 = require("ng-morph");
const constants_1 = require("../../constants");
function addCommentForStylesFiles(replaceable, pattern = [...constants_1.ALL_STYLE_FILES, ...constants_1.ALL_TS_FILES]) {
const sourceFiles = (0, ng_morph_1.getSourceFiles)(pattern);
sourceFiles.forEach((file) => {
let text = file.getFullText();
replaceable.forEach(({ sourceText, comment }) => {
const pattern = file.getFilePath().endsWith('ts')
? String.raw `((host:)(.|$|\n)*(^|\n))(?=[^\n]*${sourceText}\b)`
: String.raw `(^|\n)(?=[^\n]*${sourceText}\b)`;
const wordRegex = new RegExp(pattern, 'g');
text = text.replaceAll(wordRegex, `$1// ${comment}\n`);
file.replaceWithText(text);
});
});
}
//# sourceMappingURL=add-comment-for-styles.js.map