Fix tests for Jenkins that always build for iOS
Some checks reported warnings
gitea-openium/resgen.swift/pipeline/head This commit is unstable

This commit is contained in:
2025-04-30 12:03:57 +02:00
parent ae7c0abbc2
commit 1dbf4c643d
7 changed files with 38 additions and 36 deletions

View File

@ -22,8 +22,14 @@ struct Twine: ParsableCommand {
static let toolName = "Twine"
static let defaultExtensionName = "String"
static let twineExecutable = "\(FileManager.default.homeDirectoryForCurrentUser.relativePath)/scripts/twine/twine"
static let twineExecutable: String = {
#if os(macOS)
"\(FileManager.default.homeDirectoryForCurrentUser.relativePath)/scripts/twine/twine"
#else
fatalError("This command should run on Mac only")
#endif
}()
// MARK: - Command Options
@OptionGroup var options: TwineOptions

View File

@ -12,35 +12,13 @@ public class Shell {
public static var environment: [String: String] {
ProcessInfo.processInfo.environment
}
// @discardableResult
// public static func shell(launchPath: String = "/usr/bin/env", _ args: String...) -> (terminationStatus: Int32, output: String?) {
// let task = Process()
// task.launchPath = launchPath
// task.arguments = args
//
// var currentEnv = ProcessInfo.processInfo.environment
// for (key, value) in environment {
// currentEnv[key] = value
// }
// task.environment = currentEnv
//
// let pipe = Pipe()
// task.standardOutput = pipe
// try? task.run()
// task.waitUntilExit()
//
// let data = pipe.fileHandleForReading.readDataToEndOfFile()
//
// guard let output: String = String(data: data, encoding: .utf8) else {
// return (terminationStatus: task.terminationStatus, output: nil)
// }
//
// return (terminationStatus: task.terminationStatus, output: output)
// }
@discardableResult
public static func shell(launchPath: String = "/usr/bin/env", _ args: [String]) -> (terminationStatus: Int32, output: String?) {
public static func shell(
launchPath: String = "/usr/bin/env",
_ args: [String]
) -> (terminationStatus: Int32, output: String?) {
#if os(macOS)
let task = Process()
task.launchPath = launchPath
task.arguments = args
@ -63,5 +41,8 @@ public class Shell {
}
return (terminationStatus: task.terminationStatus, output: output)
#else
fatalError("Shell is only available on Mac")
#endif
}
}

View File

@ -60,7 +60,11 @@ public extension String {
func replaceTiltWithHomeDirectoryPath() -> Self {
// See NSString.expandingTildeInPath
#if os(macOS)
replacingOccurrences(of: "~", with: "\(FileManager.default.homeDirectoryForCurrentUser.relativePath)")
#else
fatalError("This command should run on Mac only")
#endif
}
func colorComponent() -> (alpha: String, red: String, green: String, blue: String) {