You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the devvit create icons command, the name of the asset is its relative path to the assets directory. This results in the generation of assets with an escape sequence in their name in the final TS file.
As an example, consider the following assets folder structure on Windows:
assets/
subDirectory/
vectorLogo.svg
Running devvit create icons on Windows will result in this icons.ts file:
// This file is auto-generated by `devvit create icons`. Do not edit it directly.import{svg}from"@devvit/public-api";exportconstIcons={"subDirectory\vectorLogo.svg": svg`<svg/>`}asconst;
This behavior is expected from path.relative used to get the name:
Then backslash is in fact escaped there, but becomes unescaped when writing the SVGs to the icons TS file. I think the best solution would be to replace the backslashes with forward slashes, mimicking the behavior of tinyglob and making sure asset names are the same regardless of which platform you create them on.
TLDR: const name = path.relative(assetsPath, asset); should probably be const name = path.relative(assetsPath, asset).replaceAll(path.sep, '/');
The text was updated successfully, but these errors were encountered:
When using the
devvit create icons
command, the name of the asset is its relative path to the assets directory. This results in the generation of assets with an escape sequence in their name in the final TS file.As an example, consider the following assets folder structure on Windows:
Running
devvit create icons
on Windows will result in thisicons.ts
file:This behavior is expected from
path.relative
used to get the name:devvit/packages/cli/src/commands/create/icons.ts
Line 58 in 1ac06fd
Then backslash is in fact escaped there, but becomes unescaped when writing the SVGs to the icons TS file. I think the best solution would be to replace the backslashes with forward slashes, mimicking the behavior of tinyglob and making sure asset names are the same regardless of which platform you create them on.
TLDR:
const name = path.relative(assetsPath, asset);
should probably beconst name = path.relative(assetsPath, asset).replaceAll(path.sep, '/');
The text was updated successfully, but these errors were encountered: