NJAldwin / eleventy-plugin-gen-favicons

Favicon generator plugin for eleventy
MIT License
15 stars 4 forks source link

set data to be cached to fix bug where files were always being resized #6

Closed elvece closed 1 month ago

NJAldwin commented 1 year ago

Hi, thank you for your PR! Can you please elaborate on the issue you were having, explain your change, and provide a test case showing this fixes it? I am happy to look into the issue further.

Right now, this change appears to fail all the caching tests and several others (after I fix the failing lint due to the trailing semicolon):

$ npm run test                                                                                                                                                                                                                            [18:48:28]

> eleventy-plugin-gen-favicons@1.1.2 test
> eslint *.js test/**.js && ava

  ✔ generates html with svg
  ✔ generates html without svg
  ✔ generates html without manifest
  ✔ errors on file not found
  ✔ errors on not square img
  ✔ errors on too large apple padding
  ✖ generates from test png
  ✖ generates from test svg
  ✖ caches given same src and dest
  ✖ generates with extra manifest data
  ✖ generates without manifest
  ✖ does not cache if skipCache specified
  ✖ does not cache if options differ
  ✖ generates from arbitrarily sized square pngs
  ✖ generates from arbitrarily sized square pngs with apple padding override
  ✖ does not cache if file modified
  ─

  generates from test png

  test/test.js:54

   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));
   55:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['apple'])));

  Value is not truthy:

  false

  › assertCorrectIcons (test/test.js:54:5)
  › test/test.js:96:9

  generates from test svg

  test/test.js:53

   52:
   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));

  Difference:

  - true
  + false

  › assertCorrectIcons (test/test.js:53:5)
  › test/test.js:89:9

  caches given same src and dest

  test/test.js:53

   52:
   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));

  Difference:

  - true
  + false

  › assertCorrectIcons (test/test.js:53:5)
  › test/test.js:163:9

  generates with extra manifest data

  test/test.js:53

   52:
   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));

  Difference:

  - true
  + false

  › assertCorrectIcons (test/test.js:53:5)
  › test/test.js:112:9

  generates without manifest

  test/test.js:53

   52:
   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));

  Difference:

  - true
  + false

  › assertCorrectIcons (test/test.js:53:5)
  › test/test.js:103:9

  does not cache if skipCache specified

  test/test.js:53

   52:
   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));

  Difference:

  - true
  + false

  › assertCorrectIcons (test/test.js:53:5)
  › test/test.js:182:9

  does not cache if options differ

  test/test.js:53

   52:
   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));

  Difference:

  - true
  + false

  › assertCorrectIcons (test/test.js:53:5)
  › test/test.js:224:9

  generates from arbitrarily sized square pngs

  test/test.js:54

   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));
   55:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['apple'])));

  Value is not truthy:

  false

  › assertCorrectIcons (test/test.js:54:5)
  › test/test.js:133:11
  › async test/test.js:118:3

  generates from arbitrarily sized square pngs with apple padding override

  test/test.js:54

   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));
   55:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['apple'])));

  Value is not truthy:

  false

  › assertCorrectIcons (test/test.js:54:5)
  › test/test.js:155:11
  › async test/test.js:140:3

  does not cache if file modified

  test/test.js:54

   53:   t.is(expectSvg, fs.existsSync(path.join(outDir, expectedFiles['svg'])));
   54:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['ico'])));
   55:   t.assert(fs.existsSync(path.join(outDir, expectedFiles['apple'])));

  Value is not truthy:

  false

  › assertCorrectIcons (test/test.js:54:5)
  › test/test.js:210:9

  ─

  10 tests failed
NJAldwin commented 2 months ago

Hi @elvece it has been over a year -- if you have any notes in reply to my comment above I am happy to take another look.

elvece commented 2 months ago

Hi @elvece it has been over a year -- if you have any notes in reply to my comment above I am happy to take another look.

Hi there, apologies, I spaced on this. Let me revisit this week and address your comment.

elvece commented 1 month ago

@NJAldwin I'm having trouble re-creating this on my machine (macOS 14.5), but the issue a previous co-worker on Linux (don't have system details) had was that the favicon files (specifically the apple-touch-icon.png, icon-192.png, and icon-512.png) were being regenerated every time the project was built, causing a git difference (example). IIRC the change I made fixed this for him, but I see now that it's probably not the right solution. Since I cannot re-create, I will close this PR and re-open with the appropriate details should it occur again.