srod/node-minify

Directory matching *.html in wildcard path causes uncaught error.

chrispecoraro opened this issue · 1 comments

When a directory matches the wildcard (as it does the https://github.com/sanity-io/sanity-template-kitchen-sink), the result is a fatal error in the netlify-plugin-minify-html node package which uses this package.

When the path is a directory, the behavior of fs.readFile() and fs.readFileSync() is platform-specific.

As per the documentation:

On macOS, Linux, and Windows, an error will be returned. On FreeBSD, a representation of the directory's contents will be returned.

// macOS, Linux, and Windows
fs.readFile('', (err, data) => {
// => [Error: EISDIR: illegal operation on a directory, read ]
});

// FreeBSD
fs.readFile('', (err, data) => {
// => null,
});

srod commented

Thank you, merged!