I'm trying to check a .html file, remove some tags and create a new file with the changes made.
In the method I am currently using (js, gulp) I end up doing multiple replaces in jail, I believe this is not the best way, I would like to know a better method to do this.
Here is the code for my current task:
var gulp = require("gulp");
var fs = require("fs");
gulp.task("fixes", function(done) {
var conteudo;
fs.readFile("index.html", "utf-8", (err, data) => {
if (err) throw err;
conteudo = data;
var t = data.replace(/(<body>|<\/body>)/g, "");
var final = t.replace(/<meta charset="utf-8">/, "");
fs.writeFile("dist.html", final, err => {
if (err) throw err;
});
});
console.log("Novo arquivo criado!");
done();
});