RedMadRobot / figma-export

Command line utility to export colors, typography, icons and images from Figma to Xcode / Android Studio project
MIT License
718 stars 114 forks source link

All `/` in icon name replaced with `_` before regexps applied #144

Closed osipxd closed 2 years ago

osipxd commented 2 years ago

We have icon with name icons / 24 / arrow back and I want to save it as n2_icon_arrow_back_24.xml I've configured validate and replace patterns:

nameValidateRegexp: '^icons / (\d\d) / ([A-Za-z0-9 /_-]+)$'
nameReplaceRegexp: 'n2_icon_$2_$1'
  1. Problem: Error: ❌ Bad asset name «icons _ 32 _ arrow back» Workaround: Replace / in validatingRegexp to _ (why / replaced with _?)
    nameValidateRegexp: '^icons _ (\d\d) _ ([A-Za-z0-9 /_-]+)$'
  2. Problem: Error: The file “n_2_icon_arrow_back_32.xml” doesn’t exist. (why n_2 but not n2?) Workaround: Haven't found. I've tried to remove n2 from nameReplaceRegexp, but the error is still here.
subdan commented 2 years ago
  1. FigmaExport automatically replaces symbol «/» with «_» before executing rexexps patterns because file name must not contains «/» symbol.
  2. This is a bug. I will fix it.
osipxd commented 2 years ago
  1. FigmaExport automatically replaces symbol «/» with «_» before executing rexexps patterns because file name must not contains «/» symbol.

Maybe will be better to replace symbols after nameReplaceRegexp is applied? I think it will be more intuitive.

subdan commented 2 years ago

Maybe will be better to replace symbols after nameReplaceRegexp is applied? I think it will be more intuitive.

It will break backward compatibility. Every developer that use FigmaExport will need to update their regexps. This is not good.

I will fix 2-nd bug by the end of the week. https://github.com/RedMadRobot/figma-export/issues/145

subdan commented 2 years ago

I've fixed the second bug. Please update to the latest version (0.31.7) and check again.

osipxd commented 2 years ago

I've fixed the second bug. Please update to the latest version (0.31.7) and check again.

Thanks, seems to be fixed.

Question about 1st problem. Is figma-export replaces only slashes / with underscores _?

subdan commented 2 years ago

Is figma-export replaces only slashes / with underscores _?

Yep

osipxd commented 2 years ago

Yep

It would be great if this behavior will be documented

subdan commented 2 years ago

I’ll update documentation.

subdan commented 2 years ago

Added info about replacing "/" by "_" to CONFIG.md

osipxd commented 2 years ago

Thanks! I close this issue.