Add Bundle.executable

This commit is contained in:
Max Howell
2019-02-17 10:05:24 -05:00
parent dc7affa28c
commit f4c2c75aa1
2 changed files with 6 additions and 0 deletions

View File

@@ -34,6 +34,11 @@ public extension Bundle {
var path: Path {
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`

View File

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