[Solved] edit JavaScript files using node js
I was able to edit a JavaScript file using regex. my code is below: function updateFile(filename, replacements) { return new Promise(function(resolve) { fs.readFile(filename, ‘utf-8’, function(err, data) { var regex, replaceStr; if (err) { throw (err); } else { regex = new RegExp(“(\\” + ‘let’ + “\\s* ]*” + replacements[0].rule + “\\s*=\\s*)([^\\n;}]+)([\\s*;}])”); replaceStr = “$1” + … Read more