Skip to content

Commit 625f76a

Browse files
authored
Fix path to cwebp on Apple Silicon Macs (#141)
1 parent b9919a2 commit 625f76a

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Sources/FigmaExport/Output/WebpConverter.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,27 @@ final class WebpConverter {
1919
func convert(file url: URL) throws {
2020
let outputURL = url.deletingPathExtension().appendingPathExtension("webp")
2121

22+
var executableURLs = [
23+
URL(fileURLWithPath: "/usr/local/bin/cwebp"),
24+
URL(fileURLWithPath: "/opt/homebrew/bin/cwebp")
25+
]
26+
2227
let task = Process()
23-
task.executableURL = URL(fileURLWithPath: "/usr/local/bin/cwebp")
2428
if case Encoding.lossless = encoding {
2529
task.arguments = ["-lossless", url.path, "-o", outputURL.path, "-short"]
2630
} else if case Encoding.lossy(let quality) = encoding {
2731
task.arguments = ["-q", String(quality), url.path, "-o", outputURL.path, "-short"]
2832
}
29-
try task.run()
30-
task.waitUntilExit()
33+
34+
repeat {
35+
task.executableURL = executableURLs.removeFirst()
36+
do {
37+
try task.run()
38+
task.waitUntilExit()
39+
return
40+
} catch {
41+
continue
42+
}
43+
} while !executableURLs.isEmpty
3144
}
3245
}

0 commit comments

Comments
 (0)