Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.1
39 changes: 31 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
os:
- linux
- osx
language: generic
sudo: required
dist: trusty
osx_image: xcode9
matrix:
include:
- os: linux
language: generic
sudo: required
dist: trusty
env:
- SWIFT_VERSION=4.0.3
- MAJOR_VERSION=4
- os: linux
language: generic
sudo: required
dist: trusty
env:
- SWIFT_VERSION=4.0.3
- MAJOR_VERSION=3
- os: osx
language: generic
sudo: required
osx_image: xcode9
env:
- SWIFT_VERSION=4.0.3
- MAJOR_VERSION=4
- os: osx
language: generic
sudo: required
osx_image: xcode9
env:
- SWIFT_VERSION=4.0.3
- MAJOR_VERSION=3
install:
- eval "$(curl -sL https://gist.githubusercontent.com/kylef/5c0475ff02b7c7671d2a/raw/9f442512a46d7a2af7b850d65a7e9bd31edfb09b/swiftenv-install.sh)"
script:
- swift test
- swift test -Xswiftc -swift-version -Xswiftc $MAJOR_VERSION
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# PathKit Changelog

## master

### Bug Fixes

* Fix warning with Swift 4, support 4.1
[Keith Smiley](https://github.com/keith)

## 0.9.0

### Enhancements
Expand Down
16 changes: 16 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ let package = Package(
.target(name: "PathKit", dependencies: [], path: "Sources"),
.testTarget(name: "PathKitTests", dependencies: ["PathKit", "Spectre"], path:"Tests/PathKitTests")
],
swiftLanguageVersions: [3]
swiftLanguageVersions: [3, 4]
)
24 changes: 17 additions & 7 deletions Sources/PathKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public struct Path {
path = "."
} else if components.first == Path.separator && components.count > 1 {
let p = components.joined(separator: Path.separator)
path = p.substring(from: p.characters.index(after: p.startIndex))
path = String(p[p.index(after: p.startIndex)...])
} else {
path = components.joined(separator: Path.separator)
}
Expand Down Expand Up @@ -276,10 +276,10 @@ extension Path {
guard Path.fileManager.fileExists(atPath: normalize().path, isDirectory: &directory) else {
return false
}
#if os(Linux)
return directory
#else
#if !os(Linux) || swift(>=4.1)
return directory.boolValue
#else
return directory
#endif
}

Expand All @@ -295,10 +295,10 @@ extension Path {
guard Path.fileManager.fileExists(atPath: normalize().path, isDirectory: &directory) else {
return false
}
#if os(Linux)
return !directory
#else
#if !os(Linux) || swift(>=4.1)
return !directory.boolValue
#else
return !directory
#endif
}

Expand Down Expand Up @@ -598,13 +598,23 @@ extension Path {
#else
let matchc = gt.gl_matchc
#endif
#if swift(>=4.1)
return (0..<Int(matchc)).compactMap { index in
if let path = String(validatingUTF8: gt.gl_pathv[index]!) {
return Path(path)
}

return nil
}
#else
return (0..<Int(matchc)).flatMap { index in
if let path = String(validatingUTF8: gt.gl_pathv[index]!) {
return Path(path)
}

return nil
}
#endif
}

// GLOB_NOMATCH
Expand Down
6 changes: 3 additions & 3 deletions Tests/PathKitTests/PathKitSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ describe("PathKit") {

$0.it("can return the last component without extension") {
try expect(Path("a/b/c.d").lastComponentWithoutExtension) == "c"
#if os(Linux) // no longer necessary after Swift 4.1
try expect(Path("a/..").lastComponentWithoutExtension) == "."
#else
#if !os(Linux) || swift(>=4.1)
try expect(Path("a/..").lastComponentWithoutExtension) == ".."
#else
try expect(Path("a/..").lastComponentWithoutExtension) == "."
#endif
}

Expand Down