RedMadRobot / figma-export

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

Start separate process per file to improve logging #40

Closed maxischubert93 closed 3 years ago

maxischubert93 commented 3 years ago

I encountered a problem with exporting icons to XML for android. In case there are unsupported XML-Tags in the SVG files for the vd-tool it only tells you that there was an error. But it does not tell you in which file. So it is pretty hard to see which assets in Figma are not built correctly.

This is a suggestion to start a separate process for each file, which makes it possible to read from the logs, which file had issues while converting.

The downside is, that starting a process for each file makes the whole thing take way longer. A proper solution would probably be to adjust the vd-tool, which is not easily doable, as this tool is also just a packaging of the Android Studio VectorDrawable CLI tool.

Maybe you have a suggestion to improve this behavior.

subdan commented 3 years ago

I'll think about it on the weekend and get back to you.

subdan commented 3 years ago

Converting files one by one is about 10 times slower than batch converting. So I think we shouldn't stop using batch convert.

Solution

  1. Convert files in a directory using batch convert vd-tool -c -in "path_to_directory"
  2. If an error occurs try to convert files one by one to find “bad” file vd-tool -c -in "path_to_file"

How to check for an error:

let errorPipe = Pipe()
task.standardError = errorPipe
let errorData = errorPipe.fileHandleForReading.readDataToEndOfFile()
let error = String(decoding: errorData, as: UTF8.self)

What do you think about this solution?

maxischubert93 commented 3 years ago

I already tried this approach, sadly the vd-tool doesn't provide any useful information within the standardError. You basically get the same logs you already get from just executing it the regular way. Same thing regarding the exit code. Even tough errors happen within the vd-tool, the exit code just stays 0.

subdan commented 3 years ago

Step 1. Run vdtool for a directory. Search is not supported substring in the error string. If found go to step 2.

Step 2. Run vdtool for each file. User can read logs and find “bad” files.

maxischubert93 commented 3 years ago

I adjusted the PR to first run vd-toolin a directory. And then execute the tool per file.

I also filter the log outputs from vd-tool a little to make the whole process more readable and easier understandable from the command line.

subdan commented 3 years ago

Thanks! I will check it by the end of the week.