kangax / html-minifier

Javascript-based HTML compressor/minifier (with Node.js support)
http://kangax.github.io/html-minifier/
MIT License
4.94k stars 571 forks source link

html-minifier wont minify a .txt file. #1051

Open Dichill opened 4 years ago

Dichill commented 4 years ago

Node JS html-minifier wont minify a .txt file.

try {                
                        download(message.attachments.first().url);
                        var minified = require('html-minifier');   
                        var MinifyResult = minified.minify(
                            fs.readFileSync("./minified/nonminified.txt"),                          
                                {
                                    removeAttributeQuotes: true
                                }                               
                        );  
                        await sleep(5000);
                        fs.writeFile("./minified/minified.txt", fs.readFileSync("./minified/nonminified.txt"), function(err) {
                            if(err) {
                                return console.log(err);
                            }
                            // Sucess
                            console.log("Minified!");   
                        })        
                    }
                    catch(error)
                    {
                        console.log("Error");   
                    }
R4356th commented 3 years ago

This is not helpful unless you change your code to log the error.