Commit 0a9ce1e1 authored by Nikolay Gromov's avatar Nikolay Gromov

Добавил в задачу pug вывод использованных БЭМ-блоков

parent 9a925170
...@@ -307,8 +307,12 @@ gulp.task('sprite:png', function (callback) { ...@@ -307,8 +307,12 @@ gulp.task('sprite:png', function (callback) {
}); });
// Сборка Pug // Сборка Pug
let classes = [];
gulp.task('pug', function() { gulp.task('pug', function() {
const pug = require('gulp-pug'); const pug = require('gulp-pug');
const through2 = require('through2');
const chalk = require('chalk');
const getClassesFromHtml = require('get-classes-from-html');
const htmlbeautify = require('gulp-html-beautify'); const htmlbeautify = require('gulp-html-beautify');
const replace = require('gulp-replace'); const replace = require('gulp-replace');
console.log('---------- Сборка Pug'); console.log('---------- Сборка Pug');
...@@ -339,6 +343,27 @@ gulp.task('pug', function() { ...@@ -339,6 +343,27 @@ gulp.task('pug', function() {
}, },
// compileDebug: false, // compileDebug: false,
})) }))
.pipe(through2.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if(file.relative != 'blocks-demo.html'){
const data = file.contents.toString();
let thisClasses = getClassesFromHtml(data);
thisClasses.forEach(function(item, i, arr) {
if (item.indexOf('__') + 1 === 0 && item.indexOf('--') + 1 === 0) {
classes.push(item)
}
});
file.contents = new Buffer(data);
}
this.push(file);
cb();
}))
.on('end', function(){
console.log(classes);
})
.pipe(htmlbeautify()) .pipe(htmlbeautify())
// и... привет бьютификатору! // и... привет бьютификатору!
.pipe(replace(/^(\s*)(<header.+?>)(.*)(<\/header>)/gm, '$1$2\n$1 $3\n$1$4')) .pipe(replace(/^(\s*)(<header.+?>)(.*)(<\/header>)/gm, '$1$2\n$1 $3\n$1$4'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment