{"size": 1397, "ext": "js", "max_stars_repo_path": ".build/pug.js", "max_stars_repo_name": "reff/borschtik", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": ".build/pug.js", "max_issues_repo_name": "reff/borschtik", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": ".build/pug.js", "max_forks_repo_name": "reff/borschtik", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.75, "max_line_length": 93, "alphanum_fraction": 0.5454545455}
const { src, dest, task, watch, parallel, series } = require('gulp')

const pug = require('gulp-pug')
const plumber = require('gulp-plumber')
const htmlBeautifier = require('gulp-html-beautify')
const htmlBemValidator = require('gulp-html-bem-validator')
const data = require('gulp-data')
const fs = require('fs')

const path = require('path');

// Ver 1.0
// function buildPugFiles() {
//     return src(['./src/**/*.+(jade|pug)', '!./src/b_/**/*.+(jade|pug)'])
//         .pipe(plumber())
//         .pipe(pug())
//         .pipe(htmlBeautifier({
//             indentSize: 4,
//             indent_char: ' '
//         }))
//         .pipe(htmlBemValidator())
//         .pipe(dest('./test'))
// }
// Ver 1.0

function buildPugFiles() {
    let globals = JSON.parse(fs.readFileSync('./src/data.json'));
    return src(['./src/**/*.+(jade|pug)', '!./src/b_/**/*.+(jade|pug)'])
        .pipe(plumber())
        .pipe(data(function (file) {
            let locals = JSON.parse(fs.readFileSync(path.dirname(file.path) + '/data.json'));
            console.log(path.dirname(file.path))
            return Object.assign(globals || {}, locals || {});
        }))
        .pipe(pug())
        .pipe(htmlBeautifier({
            indentSize: 4,
            indent_char: ' '
        }))
        .pipe(htmlBemValidator())
        .pipe(dest('./test'))
}
exports.pug = buildPugFiles // run task: `gulp pug`
