{"size": 1092, "ext": "js", "max_stars_repo_path": "05-merge-styles/index.js", "max_stars_repo_name": "soll1992/HTML-builder", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "05-merge-styles/index.js", "max_issues_repo_name": "soll1992/HTML-builder", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "05-merge-styles/index.js", "max_forks_repo_name": "soll1992/HTML-builder", "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": 23.2340425532, "max_line_length": 75, "alphanum_fraction": 0.5201465201}
const fs = require('fs');
const promis = require('fs/promises');
const path = require("path");

const stylesPath = path.join(__dirname, "styles")
const bundlePath = path.join(__dirname, "project-dist", "bundle.css")


async function bundleCss() {
    await promis.rm(bundlePath, { recursive: true, force: true });

    function addCssFile(file) {
      fs.appendFile(bundlePath, file, (err) => {
          if (err) throw err;                    
      });
    }
  
    function readCssFile(path) {
        fs.readFile(path, "utf-8", (err, data) => {
            if (err) throw err;
  
            addCssFile(data)
        });
    } 
  
    function bundle() {
        fs.readdir(stylesPath, {withFileTypes:true}, function(err, items) {
            if (err) throw err;
            for(const item of items) {
                const itemPath = path.join(stylesPath, item.name)
                const type = path.extname(item.name);
                if (type === ".css") {
                    readCssFile(itemPath)
                }
            }
        })
    }
  
    bundle()
}

bundleCss()




