Don't verify file is executable before running it.
Also remove unneeded Equatable implementation.
This commit is contained in:
@@ -83,7 +83,7 @@ extension CommandRunning {
|
||||
// MARK: CommandError
|
||||
|
||||
/** Error type for commands. */
|
||||
public enum CommandError: Error {
|
||||
public enum CommandError: Error, Equatable {
|
||||
|
||||
/** Exit code was not zero. */
|
||||
case returnedErrorCode(command: String, errorcode: Int)
|
||||
@@ -113,19 +113,6 @@ extension CommandError: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
extension CommandError: Equatable {
|
||||
static public func == (e1: CommandError, e2: CommandError) -> Bool {
|
||||
switch (e1, e2) {
|
||||
case (.returnedErrorCode(let c1), .returnedErrorCode(let c2)):
|
||||
return c1.errorcode == c2.errorcode && c1.command == c2.command
|
||||
case (.inAccessibleExecutable(let c1), .inAccessibleExecutable(let c2)):
|
||||
return c1 == c2
|
||||
case (.inAccessibleExecutable, .returnedErrorCode), (.returnedErrorCode, .inAccessibleExecutable):
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: run
|
||||
|
||||
/// Output from a `run` command.
|
||||
|
||||
@@ -16,10 +16,11 @@ extension Process {
|
||||
///
|
||||
/// - throws: CommandError.inAccessibleExecutable if command could not be executed.
|
||||
public func launchThrowably() throws {
|
||||
guard Files.isExecutableFile(atPath: self.executableURL!.path) else {
|
||||
do {
|
||||
try run()
|
||||
} catch CocoaError.fileNoSuchFile {
|
||||
throw CommandError.inAccessibleExecutable(path: self.executableURL!.lastPathComponent)
|
||||
}
|
||||
try run()
|
||||
}
|
||||
|
||||
/// Waits until process is finished.
|
||||
|
||||
Reference in New Issue
Block a user