Add --project-directory option to generate command to easily use relative path
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
Some checks failed
gitea-openium/resgen.swift/pipeline/head There was a failure building this commit
This commit is contained in:
@ -34,7 +34,7 @@ class ImageExtensionGenerator {
|
||||
// Create file if not exists
|
||||
let fileManager = FileManager()
|
||||
if fileManager.fileExists(atPath: extensionFilePath) == false {
|
||||
Shell.shell("touch", "\(extensionFilePath)")
|
||||
Shell.shell(["touch", "\(extensionFilePath)"])
|
||||
}
|
||||
|
||||
// Generate extension
|
||||
@ -47,7 +47,7 @@ class ImageExtensionGenerator {
|
||||
// Create file if not exists
|
||||
let fileManager = FileManager()
|
||||
if fileManager.fileExists(atPath: extensionFilePath) == false {
|
||||
Shell.shell("touch", "\(extensionFilePath)")
|
||||
Shell.shell(["touch", "\(extensionFilePath)"])
|
||||
}
|
||||
|
||||
// Create extension content
|
||||
|
@ -55,7 +55,7 @@ class XcassetsGenerator {
|
||||
// Create imageset folder
|
||||
let imagesetName = "\(parsedImage.name).imageset"
|
||||
let imagesetPath = "\(xcassetsPath)/\(imagesetName)"
|
||||
Shell.shell("mkdir", "-p", imagesetPath)
|
||||
Shell.shell(["mkdir", "-p", imagesetPath])
|
||||
|
||||
// Store managed images path
|
||||
generatedAssetsPaths.append(imagesetName)
|
||||
@ -96,16 +96,22 @@ class XcassetsGenerator {
|
||||
// convert path/to/image.png -resize 200x300 path/to/output.png
|
||||
// convert path/to/image.png -resize 200x path/to/output.png
|
||||
// convert path/to/image.png -resize x300 path/to/output.png
|
||||
Shell.shell("convert", "\(imageData.path)", "-resize", "\(convertArguments.x1.width ?? "")x\(convertArguments.x1.height ?? "")", output1x)
|
||||
Shell.shell("convert", "\(imageData.path)", "-resize", "\(convertArguments.x2.width ?? "")x\(convertArguments.x2.height ?? "")", output2x)
|
||||
Shell.shell("convert", "\(imageData.path)", "-resize", "\(convertArguments.x3.width ?? "")x\(convertArguments.x3.height ?? "")", output3x)
|
||||
Shell.shell(["convert", "\(imageData.path)",
|
||||
"-resize", "\(convertArguments.x1.width ?? "")x\(convertArguments.x1.height ?? "")",
|
||||
output1x])
|
||||
Shell.shell(["convert", "\(imageData.path)",
|
||||
"-resize", "\(convertArguments.x2.width ?? "")x\(convertArguments.x2.height ?? "")",
|
||||
output2x])
|
||||
Shell.shell(["convert", "\(imageData.path)",
|
||||
"-resize", "\(convertArguments.x3.width ?? "")x\(convertArguments.x3.height ?? "")",
|
||||
output3x])
|
||||
}
|
||||
|
||||
// Write Content.json
|
||||
let imagesetContentJson = parsedImage.contentJson
|
||||
let contentJsonFilePath = "\(imagesetPath)/Contents.json"
|
||||
if fileManager.fileExists(atPath: contentJsonFilePath) == false {
|
||||
Shell.shell("touch", "\(contentJsonFilePath)")
|
||||
Shell.shell(["touch", "\(contentJsonFilePath)"])
|
||||
}
|
||||
|
||||
let contentJsonFilePathURL = URL(fileURLWithPath: contentJsonFilePath)
|
||||
@ -160,8 +166,8 @@ class XcassetsGenerator {
|
||||
}
|
||||
|
||||
// Info unavailable -> do not bypass
|
||||
let taskWidth = Shell.shell("identify", "-format", "%w", xcassetImagePath)
|
||||
let taskHeight = Shell.shell("identify", "-format", "%h", xcassetImagePath)
|
||||
let taskWidth = Shell.shell(["identify", "-format", "%w", xcassetImagePath])
|
||||
let taskHeight = Shell.shell(["identify", "-format", "%h", xcassetImagePath])
|
||||
guard taskWidth.terminationStatus == 0,
|
||||
taskHeight.terminationStatus == 0 else {
|
||||
return false
|
||||
|
@ -95,7 +95,7 @@ struct Images: ParsableCommand {
|
||||
|
||||
@discardableResult
|
||||
static func getSvgConverterPath() -> String {
|
||||
let taskSvgConverter = Shell.shell("which", "rsvg-convert")
|
||||
let taskSvgConverter = Shell.shell(["which", "rsvg-convert"])
|
||||
if taskSvgConverter.terminationStatus == 0 {
|
||||
return taskSvgConverter.output!.removeCharacters(from: CharacterSet.whitespacesAndNewlines)
|
||||
}
|
||||
|
Reference in New Issue
Block a user