Skip to content

Commit bb449ff

Browse files
authored
Merge pull request #73 from mxcl/fixes/55
typealias PathStruct and add Swift 5.5 niceness
2 parents ecbb3a6 + 14f03ab commit bb449ff

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ on:
66
- .github/workflows/ci.yml
77
schedule:
88
- cron: '3 3 * * 5' # 3:03 AM, every Friday
9+
concurrency:
10+
group: ${{ github.head_ref || 'push' }}
11+
cancel-in-progress: true
912
jobs:
1013
smoke:
1114
runs-on: macos-latest
1215
steps:
13-
- uses: technote-space/auto-cancel-redundant-job@v1
1416
- uses: actions/checkout@v2
1517
- run: swift test --generate-linuxmain
1618
- run: git diff --exit-code

Sources/Path+CommonDirectories.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,13 @@ func defaultUrl(for searchPath: FileManager.SearchPathDirectory) -> DynamicPath
108108
}
109109
#endif
110110

111+
#if swift(>=5.5)
112+
extension Pathish where Self == Path {
113+
static var home: DynamicPath { Path.home }
114+
static var root: DynamicPath { Path.root }
115+
static var cwd: DynamicPath { Path.cwd }
116+
static var documents: DynamicPath { Path.documents }
117+
static var caches: DynamicPath { Path.caches }
118+
static var applicationSupport: DynamicPath { Path.applicationSupport }
119+
}
120+
#endif

Sources/Path.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import func Glibc.realpath
77
let _realpath = Glibc.realpath
88
#endif
99

10+
public typealias PathStruct = Path
11+
1012
/**
1113
A `Path` represents an absolute path on a filesystem.
1214

Tests/PathTests/PathTests.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,20 @@ import func XCTest.XCTAssertEqual
33
import Foundation
44
import XCTest
55

6+
extension PathStruct {
7+
var foo: Int { fatalError()}
8+
}
9+
610
class PathTests: XCTestCase {
11+
func testNewStuff() {
12+
#if swift(>=5.5)
13+
func foo<P: Pathish>(_ path: P) {}
14+
15+
foo(.home)
16+
foo(.root)
17+
#endif
18+
}
19+
720
func testConcatenation() {
821
XCTAssertEqual((Path.root/"bar").string, "/bar")
922
XCTAssertEqual(Path.cwd.string, FileManager.default.currentDirectoryPath)

Tests/PathTests/XCTestManifests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ extension PathTests {
4545
("testMktemp", testMktemp),
4646
("testMoveInto", testMoveInto),
4747
("testMoveTo", testMoveTo),
48+
("testNewStuff", testNewStuff),
4849
("testNoUndesiredSymlinkResolution", testNoUndesiredSymlinkResolution),
4950
("testOptionalInitializer", testOptionalInitializer),
5051
("testParent", testParent),

0 commit comments

Comments
 (0)