Merge pull request #43 from mxcl/Bundle.executable

Add Bundle.executable
This commit is contained in:
repo-ranger[bot]
2019-02-17 15:14:17 +00:00
committed by GitHub
2 changed files with 6 additions and 0 deletions

View File

@@ -34,6 +34,11 @@ public extension Bundle {
var path: Path { var path: Path {
return Path(string: bundlePath) return Path(string: bundlePath)
} }
/// Returns the executable for this bundle, if there is one, not all bundles have one hence `Optional`.
var executable: Path? {
return executablePath.flatMap(Path.init)
}
} }
/// Extensions on `String` that work with `Path` rather than `String` or `URL` /// Extensions on `String` that work with `Path` rather than `String` or `URL`

View File

@@ -403,6 +403,7 @@ class PathTests: XCTestCase {
XCTAssertEqual(bndl.privateFrameworks, tmpdir.Frameworks) XCTAssertEqual(bndl.privateFrameworks, tmpdir.Frameworks)
XCTAssertEqual(bndl.resources, tmpdir) XCTAssertEqual(bndl.resources, tmpdir)
XCTAssertNil(bndl.path(forResource: "foo", ofType: "bar")) XCTAssertNil(bndl.path(forResource: "foo", ofType: "bar"))
XCTAssertNil(bndl.executable)
#if os(macOS) #if os(macOS)
XCTAssertEqual(bndl.defaultSharedFrameworksPath, tmpdir.Contents.Frameworks) XCTAssertEqual(bndl.defaultSharedFrameworksPath, tmpdir.Contents.Frameworks)