11ty/eleventy-fetch

Saving asset when no .cache directory exists causes error

brettdewoody opened this issue · 1 comments

I was attempting to use/create an Asset Cache for a response from the Google API (using theiir Node library). I deleted my .cache directory to test if it was working and starting getting the following:

> ENOENT: no such file or directory, open '.cache/eleventy-cache-assets-google_calender_events.json'
[0] 
[0] `Error` was thrown:
[0]     Error: ENOENT: no such file or directory, open '.cache/eleventy-cache-assets-google_calender_events.json'

If I create an empty .cache directory it seems to work fine.

The culprit seems to be the AssetCache.save method. Should this check for the .cache directory and create it if it doesn't exist?

Note that I followed the tutorial for the plugin to get this error. It assumes the .cache directory already exists.

Shipping with v2.3.0