Minify: Treat ENOTDIR like ENOENT when statting a file

This avoids an exception when require-kernel requests a path like
`existing-file.js/index.js`.
This commit is contained in:
Richard Hansen 2021-04-21 16:26:24 -04:00
parent aaacbd3a7a
commit e8df643d75

View file

@ -247,7 +247,7 @@ const statFile = async (filename, dirStatLimit) => {
try {
stats = await fs.stat(path.resolve(ROOT_DIR, filename));
} catch (err) {
if (err.code === 'ENOENT') {
if (['ENOENT', 'ENOTDIR'].includes(err.code)) {
// Stat the directory instead.
const [date] = await statFile(path.dirname(filename), dirStatLimit - 1);
return [date, false];