WordPress / community-themes

A collection of Block Themes built by the WordPress community.
80 stars 33 forks source link

Escape patterns script not working correctly #154

Open MaggieCabrera opened 6 months ago

MaggieCabrera commented 6 months ago

While working on https://github.com/WordPress/community-themes/pull/152 I tried to use the escape patterns script and it was failing:


> community-themes@1.0.0 patterns:escape
> node ./theme-utils.mjs escape-patterns

╔══════════════════════════════════════════╗
║              THEME: poetry               ║
║                                          ║
║  Following patterns may get updated with ║
║    escaped strings and/or image paths    ║
╟──────────────────────────────────────────╢
║ poetry/patterns/posts.php                ║
╟──────────────────────────────────────────╢
║ poetry/patterns/index.php                ║
╚══════════════════════════════════════════╝

? Verify the theme slug poetry
node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open 'poetry/patterns/index.php'
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'poetry/patterns/index.php'
}
joanrodas commented 5 months ago

This error seems to happen when you delete or rename a file from the patterns folder without commiting to git. If you change the file contents and run the command, the script seems to work fine. Captura de pantalla de 2024-04-05 19-59-01

Steps to reproduce error:

  1. Delete or rename a pattern file (for example poetry/index.php)
  2. Run npm run patterns:escape
MaggieCabrera commented 5 months ago

@joanrodas I can avoid the error if I don't rename the file but it still doesn't escape the strings, so the script still needs some debugging apparently. Thanks for your help!