const { html: beautify_html } = require('js-beautify') const path = require('path') const SVGO = require('svgo') const target = path.join(__dirname, '../public/') const xmlRegex = /\.(html|xml)$/ const jsonRegex = /\.json$/ const svgRegex = /\.svg$/ getFilePaths(target, tidyPath) function getFilePaths(input, cb) { let items = readDir(input) const stat = fs.statSync(item) if (stat.isDirectory()) { const nueveau = readDir(item) } else if (stat.isFile()) { return fs.readdirSync(item).map(i => path.join(item, i)) function tidyPath(path) { if (path.match(xmlRegex)) { const data = fs.readFileSync(path, 'utf8') max_preserve_newlines: 0, console.log(`Error Tidiyng ${path}`, err) console.log(`Tidied path: ${path.replace(target, '')}`) } else if (path.match(jsonRegex)) { const data = fs.readFileSync(path, 'utf8') fs.writeFile(path, JSON.stringify(JSON.parse(data)), err => { console.log(`Error minifying ${path}`, err) console.log(`Minified path: ${path.replace(target, '')}`) } else if (path.match(svgRegex)) { const data = fs.readFileSync(path, 'utf8') fs.writeFileSync(path, d.data) console.log(`Optimised: ${path.replace(target, '')}`) .catch(err => console.log(`Error Optimising SVG ${path}`, err))