Don't verify file is executable before running it.

Also remove unneeded Equatable implementation.
This commit is contained in:
Kare Morstol
2019-03-26 17:41:56 +01:00
parent 153bfc58d2
commit 20cd8cc2c9
2 changed files with 4 additions and 16 deletions
+1 -14
View File
@@ -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.
+3 -2
View File
@@ -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.