From 6ff91b2b5738a50b2fb79ee476bba2f5db34f0e4 Mon Sep 17 00:00:00 2001 From: Kare Morstol Date: Tue, 6 Oct 2015 18:25:08 +0200 Subject: [PATCH] Make pathForExecutable an inner function. --- SwiftShell/Command.swift | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/SwiftShell/Command.swift b/SwiftShell/Command.swift index 3095f9e..16cc1f3 100644 --- a/SwiftShell/Command.swift +++ b/SwiftShell/Command.swift @@ -44,19 +44,20 @@ public protocol ShellRunnable { extension ShellRunnable { - /** - If `executable` is not a path and a path for an executable file of that name can be found, return that path. - Otherwise just return `executable`. - */ - private func pathForExecutable (executable: String) -> String { - guard !executable.characters.contains("/") else { - return executable - } - let path = self.run("/usr/bin/which", executable) - return path.isEmpty ? executable : path - } - func createTask (executable: String, args: [String]) -> NSTask { + + /** + If `executable` is not a path and a path for an executable file of that name can be found, return that path. + Otherwise just return `executable`. + */ + func pathForExecutable (executable: String) -> String { + guard !executable.characters.contains("/") else { + return executable + } + let path = self.run("/usr/bin/which", executable) + return path.isEmpty ? executable : path + } + let task = NSTask() task.arguments = args task.launchPath = pathForExecutable(executable)