Skip to content

Commit 8d6ffc9

Browse files
maximilian.schubertsubdan
authored andcommitted
Start separate process per file to improve logging
1 parent 4376bba commit 8d6ffc9

File tree

3 files changed

+22
-16
lines changed

3 files changed

+22
-16
lines changed
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
1-
import Foundation
21
import FigmaExportCore
2+
import Foundation
33

44
/// SVG to XML converter
55
final class VectorDrawableConverter {
6-
76
/// Converts SVG files to XML
8-
/// - Parameter inputDirectoryPath: Path to directory with SVG files
9-
func convert(inputDirectoryPath: String) throws {
10-
let task = Process()
11-
task.executableURL = URL(fileURLWithPath: "/usr/local/bin/vd-tool")
12-
task.arguments = ["-c", "-in", inputDirectoryPath]
13-
do {
14-
try task.run()
15-
} catch {
16-
task.executableURL = URL(fileURLWithPath: "./vd-tool/bin/vd-tool")
17-
try task.run()
7+
/// - Parameter inputDirectoryUrl: Url to directory with SVG files
8+
func convert(inputDirectoryUrl: URL) throws {
9+
let enumerator = FileManager.default.enumerator(at: inputDirectoryUrl, includingPropertiesForKeys: nil)
10+
11+
while let file = enumerator?.nextObject() as? URL {
12+
guard file.pathExtension == "svg" else { return }
13+
let task = Process()
14+
task.executableURL = URL(fileURLWithPath: "/usr/local/bin/vd-tool")
15+
task.arguments = ["-c", "-in", file.path, "-out", inputDirectoryUrl.path]
16+
17+
do {
18+
try task.run()
19+
} catch {
20+
task.executableURL = URL(fileURLWithPath: "./vd-tool/bin/vd-tool")
21+
try task.run()
22+
}
23+
24+
task.waitUntilExit()
1825
}
19-
task.waitUntilExit()
2026
}
2127
}

Sources/FigmaExport/Subcommands/ExportIcons.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ extension FigmaExportCommand {
142142

143143
// 5. Convert all SVG to XML files
144144
logger.info("Converting SVGs to XMLs...")
145-
try svgFileConverter.convert(inputDirectoryPath: tempDirectoryURL.path)
145+
try svgFileConverter.convert(inputDirectoryUrl: tempDirectoryURL)
146146

147147
// Create output directory main/res/custom-directory/drawable/
148148
let outputDirectory = URL(fileURLWithPath: android.mainRes

Sources/FigmaExport/Subcommands/ExportImages.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ extension FigmaExportCommand {
162162

163163
// Convert all SVG to XML files
164164
logger.info("Converting SVGs to XMLs...")
165-
try svgFileConverter.convert(inputDirectoryPath: tempDirectoryLightURL.path)
165+
try svgFileConverter.convert(inputDirectoryUrl: tempDirectoryLightURL)
166166
if images.first?.dark != nil {
167167
logger.info("Converting dark SVGs to XMLs...")
168-
try svgFileConverter.convert(inputDirectoryPath: tempDirectoryDarkURL.path)
168+
try svgFileConverter.convert(inputDirectoryUrl: tempDirectoryDarkURL)
169169
}
170170

171171
logger.info("Writting files to Android Studio project...")

0 commit comments

Comments
 (0)