text: const fs = require ('fs');
  const path = require ('path');
  const roadStyles = path.join(__dirname, 'styles');
  const roadComponents = path.join(__dirname, 'components');
  const roadProjectDist = path.join(__dirname, 'project-dist');
  const roadProjectDistAssets = path.join(__dirname, 'project-dist', 'assets');
  const roadIndex = path.join(roadProjectDist, 'index.html');
  const roadAssets = path.join(__dirname, 'assets');
  
  let template = fs.createReadStream(path.join(__dirname, 'template.html'), 'utf-8');
  
  
  fs.mkdir(roadProjectDist, {recursive : true}, err => {
     if (err) throw err;
     console.log("project-dist");
   });
  
  
  // --------------------------------Make Index-----------------------
  function makeIndex () {
     template.on('data', (chunk) => {
        let halfFile = chunk;
        fs.readdir(roadComponents, {withFileTypes: true}, (err, data) => {
           data.forEach(element => {
              if(element.isFile()) {
                 if (path.extname(element.name) === '.html') {
                    const readding = fs.createReadStream(path.join(roadComponents, element.name), 'utf-8');
                    readding.on('error', error => console.log(error.message));
                    readding.on('data', (chunk) => {
                       const nameTags = '{{'+path.basename(element.name).slice(0, -5)+'}}';
                       const note = chunk;
                       const regExp = new RegExp(nameTags, 'g')
                       halfFile = halfFile.replace(regExp, note)
                       fs.writeFile(roadIndex, halfFile, () => {})
                    })
                 }
              }
           })
        })
     })
  }
  makeIndex()
  
  // --------------------------------------Make Style---------------------------
  function makeStyle () {
     fs.readdir(roadStyles, {withFileTypes: true}, (error, data) =>{
        if (error) return console.error(error.message);
        let writing = fs.createWriteStream(path.join(__dirname, 'project-dist', 'style.css'), 'utf-8');
        data.forEach(element => {
          if (element.isFile()) {
            fs.stat(path.join(__dirname, 'styles', element.name), (err) => {
              if (err) return console.error(err.message);
              if (path.extname(element.name) === '.css') {
                let readding = fs.createReadStream(path.join(__dirname, 'styles', element.name), 'utf-8');
                readding.on('data', partData => writing.write(partData));
                readding.on('error', error => console.log( error.message));
              }
                
            });
          }
           
        });
         
      });
  }
  makeStyle()
  
  // --------------------------------------Copy assets---------------------------
  function copyAssets (dirPath) {
    fs.readdir(dirPath, { withFileTypes: true }, (err, files) => {
        files.forEach(file => {
            const filePath = path.join(dirPath, file.name)
            const relativePath = filePath.slice(__dirname.length, filePath.length)
            const filePathCopy = path.join(roadProjectDist, relativePath)
  
  
            if (file.isFile()) {
                fs.copyFile(filePath, filePathCopy, err => { })
            } else {
                fs.mkdir(filePathCopy, { recursive: true }, (err) => {
                 copyAssets(filePath)
                })
            }
        })
    })  
   
     
  }
  copyAssets(roadAssets)