-
-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Danger executor
- Loading branch information
Showing
13 changed files
with
90 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import DangerShellExecutor | ||
import Foundation | ||
|
||
/// Utility functions that make Dangerfiles easier to write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,14 @@ | ||
import DangerShellExecutor | ||
import Logger | ||
import ShellOut | ||
|
||
public final class DangerJSVersionFinder { | ||
public static func findDangerJSVersion(dangerJSPath: String) throws -> String { | ||
return try findDangerJSVersion(dangerJSPath: dangerJSPath, executor: ShellOutExecutor()) | ||
return try findDangerJSVersion(dangerJSPath: dangerJSPath, executor: ShellExecutor()) | ||
} | ||
|
||
static func findDangerJSVersion(dangerJSPath: String, executor: ShellOutExecuting) throws -> String { | ||
static func findDangerJSVersion(dangerJSPath: String, executor: ShellExecuting) throws -> String { | ||
Logger().debug("Finding danger-js version") | ||
|
||
return try executor.shellOut(command: dangerJSPath + " --version") | ||
} | ||
} | ||
|
||
public protocol ShellOutExecuting { | ||
@discardableResult | ||
func shellOut(command: String) throws -> String | ||
} | ||
|
||
public struct ShellOutExecutor: ShellOutExecuting { | ||
public init() {} | ||
|
||
public func shellOut(command: String) throws -> String { | ||
return try ShellOut.shellOut(to: command) | ||
return executor.execute(dangerJSPath, arguments: ["--version"]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import DangerShellExecutor | ||
import Foundation | ||
import Logger | ||
import ShellOut | ||
|
||
public func getDangerCommandPath(logger: Logger, args: [String] = CommandLine.arguments, shellOutExecutor: ShellOutExecuting = ShellOutExecutor()) throws -> String { | ||
public func getDangerCommandPath(logger: Logger, | ||
args: [String] = CommandLine.arguments, | ||
shellOutExecutor: ShellExecuting = ShellExecutor()) throws -> String { | ||
if let dangerJSPathOptionIndex = args.firstIndex(of: DangerSwiftOption.dangerJSPath.rawValue), | ||
dangerJSPathOptionIndex + 1 < args.count { | ||
return args[dangerJSPathOptionIndex + 1] | ||
} else { | ||
logger.debug("Finding out where the danger executable is") | ||
return try shellOutExecutor.shellOut(command: "which danger").trimmingCharacters(in: .whitespaces) | ||
return try shellOutExecutor.spawn("which danger", arguments: []).trimmingCharacters(in: .whitespaces) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters