Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const MDS_path = '/home/nikita/Загрузки/123/';
- const style2_path = '/home/nikita/work/epbs-default/EPBS-Portal/EpbsStatic/Static/public_html/css/style2.css';
- const MDS_classes = [];
- const style2_classes = [];
- function showFiles(path) {
- const files = fs.readdirSync(path);
- files.forEach(file => {
- const isDirectory = fs.statSync(`${path}${file}`).isDirectory();
- if (isDirectory) {
- showFiles(`${path}${file}/`)
- } else if (file.toLowerCase().indexOf('page') > -1 && (file.endsWith('jspx') || file.endsWith('xml'))) {
- addCssClasses(`${path}${file}`);
- }
- });
- }
- function addCssClasses(path) {
- const htmlPage = fs.readFileSync(path, 'utf8');
- let index = 0;
- while (index > -1) {
- index = htmlPage.indexOf('class="', index + 7);
- if (index > -1) {
- const className = htmlPage.substring(index + 7, htmlPage.indexOf('"', index + 7));
- if (MDS_classes.indexOf(className) === -1) {
- MDS_classes.push(className);
- }
- }
- }
- index = 0;
- while (index > -1) {
- index = htmlPage.indexOf('styleClass="', index + 12);
- if (index > -1) {
- const className = htmlPage.substring(index + 12, htmlPage.indexOf('"', index + 12));
- if (MDS_classes.indexOf(className) === -1) {
- MDS_classes.push(className);
- }
- }
- }
- index = 0;
- while (index > -1) {
- index = htmlPage.indexOf('class="', index + 12);
- if (index > -1) {
- const className = htmlPage.substring(index + 12, htmlPage.indexOf('"', index + 12));
- if (MDS_classes.indexOf(className) === -1) {
- MDS_classes.push(className);
- }
- }
- }
- index = 0;
- while (index > -1) {
- index = htmlPage.indexOf('class=\'', index + 7);
- if (index > -1) {
- const className = htmlPage.substring(index + 7, htmlPage.indexOf('\'', index + 7));
- if (MDS_classes.indexOf(className) === -1) {
- MDS_classes.push(className);
- }
- }
- }
- }
- showFiles(MDS_path);
- checkClasses(1);
- function checkClasses(count) {
- if (count === MDS_classes.length) {
- console.log(MDS_classes.length);
- style2ClassesFind();
- } else {
- setTimeout(() => checkClasses(MDS_classes.length), 50);
- }
- }
- function style2ClassesFind() {
- const lineReader = require('readline').createInterface({
- input: require('fs').createReadStream(style2_path)
- });
- lineReader.on('line', function (line) {
- if (line.trim().startsWith("."))
- console.log('Line from file:', line.trim());
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement