Fix crash that can happen when files are deleted

Thu Apr 03 2025

tucker.mcknight@gmail.com

This happens if a file is deleted and you regenerate
the site before recording the change that marks the file
as deleted.

23f67834ca81c41db55f458e98c1eac612b3a56a

darcs pull https://repos.tuckerm.us/repos/eleventy-darcs/branches/main -h 23f67834ca81c41db55f458e98c1eac612b3a56a
eleventy.config.js:41
Before
const fileInfo = await fs.stat(`${darcsConfig.repos[repo].location}/${filename}`)
      return fileInfo .isDirectory() 
After
    try {
      const fileInfo = await fs.stat(`${darcsConfig.repos[repo].location}/${filename}`)
      return fileInfo ? fileInfo.isDirectory() : false
    }
    catch {
      return false // this can happen if a file is deleted and we're generating the
                   // site before recording the patch, so it's still trying to find
                   // all of the files in `darcs show files`.
    }
helpers.js:69
Before
      if (file === "_data/paginatedPatches.js") {
        console.log(previousDiffMarkers)
      }
After