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`.
pull/5015/head
Richard Hansen 2021-04-21 16:26:24 -04:00
parent aaacbd3a7a
commit e8df643d75
1 changed files with 1 additions and 1 deletions

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];