Compare commits
6 Commits
1.0.0-alph
...
1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f062ed9ce3 | ||
|
|
f1f7ee33b1 | ||
|
|
694d04f18b | ||
|
|
5636a7ac65 | ||
|
|
3e964833ff | ||
|
|
30122659a5 |
47
.travis.yml
47
.travis.yml
@@ -1,10 +1,14 @@
|
|||||||
# only run for: merge commits, releases and pull-requests
|
# only run for: merge commits, releases and pull-requests
|
||||||
if: type != push OR branch = master OR branch =~ /^\d+\.\d+\.\d+(-.*)?$/
|
if: type != push OR branch = master OR branch =~ /^deploy-\d+\.\d+\.\d+(-.*)?$/ OR branch =~ /^\d+\.\d+\.\d+(-.*)?$/
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- name: pretest
|
- name: pretest
|
||||||
|
if: NOT branch =~ /^deploy-\d+\.\d+\.\d+(-.*)?$/
|
||||||
- name: test
|
- name: test
|
||||||
|
if: NOT branch =~ /^deploy-\d+\.\d+\.\d+(-.*)?$/
|
||||||
- name: deploy
|
- name: deploy
|
||||||
|
if: branch =~ /^deploy-\d+\.\d+\.\d+(-.*)?$/
|
||||||
|
- name: publish
|
||||||
if: branch =~ /^\d+\.\d+\.\d+(-.*)?$/
|
if: branch =~ /^\d+\.\d+\.\d+(-.*)?$/
|
||||||
|
|
||||||
os: osx
|
os: osx
|
||||||
@@ -16,18 +20,21 @@ xcode_scheme: Path.swift-Package
|
|||||||
jobs:
|
jobs:
|
||||||
include:
|
include:
|
||||||
- name: macOS / Swift 4.0.3
|
- name: macOS / Swift 4.0.3
|
||||||
|
before_script: swift build -Xswiftc -warnings-as-errors
|
||||||
script: swift test --parallel -Xswiftc -swift-version -Xswiftc 4
|
script: swift test --parallel -Xswiftc -swift-version -Xswiftc 4
|
||||||
|
|
||||||
- name: macOS / Swift 4.2.1
|
- &std
|
||||||
|
name: macOS / Swift 4.2.1
|
||||||
|
before_script: swift build -Xswiftc -warnings-as-errors
|
||||||
script: swift test --parallel
|
script: swift test --parallel
|
||||||
|
|
||||||
- name: macOS / Swift 5.0
|
- <<: *std
|
||||||
|
name: macOS / Swift 5.0
|
||||||
osx_image: xcode10.2
|
osx_image: xcode10.2
|
||||||
script: swift test --parallel
|
|
||||||
|
|
||||||
- name: macOS / Swift 5.1
|
- <<: *std
|
||||||
|
name: macOS / Swift 5.1
|
||||||
osx_image: xcode11
|
osx_image: xcode11
|
||||||
script: swift test --parallel
|
|
||||||
|
|
||||||
- &xcodebuild
|
- &xcodebuild
|
||||||
before_install: swift package generate-xcodeproj --enable-code-coverage
|
before_install: swift package generate-xcodeproj --enable-code-coverage
|
||||||
@@ -57,15 +64,20 @@ jobs:
|
|||||||
language: generic
|
language: generic
|
||||||
sudo: false
|
sudo: false
|
||||||
install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
|
install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
|
||||||
|
before_script: swift build -Xswiftc -warnings-as-errors
|
||||||
script: swift test --parallel
|
script: swift test --parallel
|
||||||
|
|
||||||
- <<: *linux
|
- <<: *linux
|
||||||
env: SWIFT_VERSION='5.0.2'
|
env: SWIFT_VERSION=5.0.3
|
||||||
name: Linux / Swift 5.0.2
|
name: Linux / Swift 5.0.3
|
||||||
|
|
||||||
- <<: *linux
|
- <<: *linux
|
||||||
env: SWIFT_VERSION=5.1-DEVELOPMENT-SNAPSHOT-2019-07-03-a
|
env: SWIFT_VERSION=5.1.3
|
||||||
name: Linux / Swift 5.1 (2019-07-03)
|
name: Linux / Swift 5.1.3
|
||||||
|
|
||||||
|
- <<: *linux
|
||||||
|
env: SWIFT_VERSION=5.2-DEVELOPMENT-SNAPSHOT-2020-01-22-a
|
||||||
|
name: Linux / Swift 5.2.0-dev+2020-01-22-a
|
||||||
|
|
||||||
- stage: pretest
|
- stage: pretest
|
||||||
name: Check Linux tests are sync’d
|
name: Check Linux tests are sync’d
|
||||||
@@ -74,6 +86,21 @@ jobs:
|
|||||||
osx_image: xcode10.2
|
osx_image: xcode10.2
|
||||||
|
|
||||||
- stage: deploy
|
- stage: deploy
|
||||||
|
name: Deploy
|
||||||
|
osx_image: xcode11
|
||||||
|
env: HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||||
|
install: brew install mxcl/made/swift-sh
|
||||||
|
script:
|
||||||
|
- set -e
|
||||||
|
- export VERSION=$(echo $TRAVIS_TAG | cut -c 8-)
|
||||||
|
- git tag "$VERSION"
|
||||||
|
- git remote set-url origin "https://$GITHUB_TOKEN@github.com/$TRAVIS_REPO_SLUG.git"
|
||||||
|
- git fetch --unshallow origin
|
||||||
|
- git push origin "$VERSION"
|
||||||
|
- swift sh <(curl https://raw.githubusercontent.com/mxcl/ops/master/deploy) publish-release
|
||||||
|
- git push origin :$TRAVIS_TAG
|
||||||
|
|
||||||
|
- stage: publish
|
||||||
name: Jazzy
|
name: Jazzy
|
||||||
osx_image: xcode10.2
|
osx_image: xcode10.2
|
||||||
install: gem install jazzy
|
install: gem install jazzy
|
||||||
|
|||||||
25
README.md
25
README.md
@@ -44,10 +44,8 @@ Swift), we provide a thoughtful and comprehensive (yet concise) API.
|
|||||||
|
|
||||||
# Support mxcl
|
# Support mxcl
|
||||||
|
|
||||||
Hi, I’m Max Howell and I have written a lot of open source software, and
|
Hi, I’m Max Howell and I have written a lot of open source software—generally
|
||||||
probably you already use some of it (Homebrew anyone?). I work full-time on
|
a good deal of my free time 👨🏻💻.
|
||||||
open source and it’s hard; currently I earn *less* than minimum wage. Please
|
|
||||||
help me continue my work, I appreciate it x
|
|
||||||
|
|
||||||
<a href="https://www.patreon.com/mxcl">
|
<a href="https://www.patreon.com/mxcl">
|
||||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
||||||
@@ -183,7 +181,7 @@ Path.home.find().execute { path in
|
|||||||
Which is configurable:
|
Which is configurable:
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
Path.home.find().maxDepth(1).extension("swift").kind(.file) { path in
|
Path.home.find().depth(max: 1).extension("swift").type(.file) { path in
|
||||||
//…
|
//…
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -300,7 +298,7 @@ for that as the check was deemed too expensive to be worthwhile.
|
|||||||
If a `Path` is a symlink but the destination of the link does not exist `exists`
|
If a `Path` is a symlink but the destination of the link does not exist `exists`
|
||||||
returns `false`. This seems to be the correct thing to do since symlinks are
|
returns `false`. This seems to be the correct thing to do since symlinks are
|
||||||
meant to be an abstraction for filesystems. To instead verify that there is
|
meant to be an abstraction for filesystems. To instead verify that there is
|
||||||
no filesystem entry there at all check if `kind` is `nil`.
|
no filesystem entry there at all check if `type` is `nil`.
|
||||||
|
|
||||||
|
|
||||||
## We do not provide change directory functionality
|
## We do not provide change directory functionality
|
||||||
@@ -337,28 +335,19 @@ actual filesystem path, however we also check the URL has a `file` scheme first.
|
|||||||
SwiftPM:
|
SwiftPM:
|
||||||
|
|
||||||
```swift
|
```swift
|
||||||
package.append(.package(url: "https://github.com/mxcl/Path.swift.git", from: "0.13.0"))
|
package.append(.package(url: "https://github.com/mxcl/Path.swift.git", from: "1.0.0"))
|
||||||
```
|
```
|
||||||
|
|
||||||
CocoaPods:
|
CocoaPods:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
pod 'Path.swift', '~> 0.13'
|
pod 'Path.swift', '~> 1.0.0'
|
||||||
```
|
```
|
||||||
|
|
||||||
Carthage:
|
Carthage:
|
||||||
|
|
||||||
> Waiting on: [@Carthage#1945](https://github.com/Carthage/Carthage/pull/1945).
|
> Waiting on: [@Carthage#1945](https://github.com/Carthage/Carthage/pull/1945).
|
||||||
|
|
||||||
## Pre‐1.0 status
|
|
||||||
|
|
||||||
We are pre 1.0, thus we can change the API as we like, and we will (to the
|
|
||||||
pursuit of getting it *right*)! We will tag 1.0 as soon as possible.
|
|
||||||
|
|
||||||
### Get push notifications for new releases
|
|
||||||
|
|
||||||
https://mxcl.dev/canopy/
|
|
||||||
|
|
||||||
# Alternatives
|
# Alternatives
|
||||||
|
|
||||||
* [Pathos](https://github.com/dduan/Pathos) by Daniel Duan
|
* [Pathos](https://github.com/dduan/Pathos) by Daniel Duan
|
||||||
@@ -368,7 +357,7 @@ https://mxcl.dev/canopy/
|
|||||||
|
|
||||||
|
|
||||||
[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg
|
[badge-platforms]: https://img.shields.io/badge/platforms-macOS%20%7C%20Linux%20%7C%20iOS%20%7C%20tvOS%20%7C%20watchOS-lightgrey.svg
|
||||||
[badge-languages]: https://img.shields.io/badge/swift-4.2%20%7C%205.0-orange.svg
|
[badge-languages]: https://img.shields.io/badge/swift-4.2%20%7C%205.0%20%7C%205.1%20%7C%205.2-orange.svg
|
||||||
[docs]: https://mxcl.dev/Path.swift/Structs/Path.html
|
[docs]: https://mxcl.dev/Path.swift/Structs/Path.html
|
||||||
[badge-jazzy]: https://raw.githubusercontent.com/mxcl/Path.swift/gh-pages/badge.svg?sanitize=true
|
[badge-jazzy]: https://raw.githubusercontent.com/mxcl/Path.swift/gh-pages/badge.svg?sanitize=true
|
||||||
[badge-codecov]: https://codecov.io/gh/mxcl/Path.swift/branch/master/graph/badge.svg
|
[badge-codecov]: https://codecov.io/gh/mxcl/Path.swift/branch/master/graph/badge.svg
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ public extension Pathish {
|
|||||||
if overwrite, let tokind = to.type, tokind != .directory, type != .directory {
|
if overwrite, let tokind = to.type, tokind != .directory, type != .directory {
|
||||||
try FileManager.default.removeItem(at: to.url)
|
try FileManager.default.removeItem(at: to.url)
|
||||||
}
|
}
|
||||||
#if os(Linux) && !swift(>=5.2) // check if fixed
|
#if os(Linux) && !swift(>=5.3) // check if fixed
|
||||||
if !overwrite, to.kind != nil {
|
if !overwrite, to.type != nil {
|
||||||
throw CocoaError.error(.fileWriteFileExists)
|
throw CocoaError.error(.fileWriteFileExists)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -69,8 +69,8 @@ public extension Pathish {
|
|||||||
if overwrite, let kind = rv.type, kind != .directory {
|
if overwrite, let kind = rv.type, kind != .directory {
|
||||||
try FileManager.default.removeItem(at: rv.url)
|
try FileManager.default.removeItem(at: rv.url)
|
||||||
}
|
}
|
||||||
#if os(Linux) && !swift(>=5.2) // check if fixed
|
#if os(Linux) && !swift(>=5.3) // check if fixed
|
||||||
if !overwrite, rv.kind != nil {
|
if !overwrite, rv.type != nil {
|
||||||
throw CocoaError.error(.fileWriteFileExists)
|
throw CocoaError.error(.fileWriteFileExists)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -204,7 +204,7 @@ public extension Pathish {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Renames the file at path.
|
Renames the file (basename only) at path.
|
||||||
|
|
||||||
Path.root.foo.bar.rename(to: "baz") // => /foo/baz
|
Path.root.foo.bar.rename(to: "baz") // => /foo/baz
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public extension Path {
|
|||||||
|
|
||||||
private let enumerator: FileManager.DirectoryEnumerator!
|
private let enumerator: FileManager.DirectoryEnumerator!
|
||||||
|
|
||||||
/// The range of directory depths for which the find operation will return entries.b
|
/// The range of directory depths for which the find operation will return entries.
|
||||||
private(set) public var depth: ClosedRange<Int> = 1...Int.max
|
private(set) public var depth: ClosedRange<Int> = 1...Int.max
|
||||||
|
|
||||||
/// The kinds of filesystem entries find operations will return.
|
/// The kinds of filesystem entries find operations will return.
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ public extension Pathish {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
- Returns: `true` if the path represents an actual filesystem entry.
|
- Returns: `true` if the path represents an actual filesystem entry.
|
||||||
- Note: If `self` is a symlink the return value represents the destination.
|
- Note: If `self` is a symlink the return value represents the destination, thus if the destination doesn’t exist this returns `false` even if the symlink exists.
|
||||||
|
- Note: To determine if a symlink exists, use `.type`.
|
||||||
*/
|
*/
|
||||||
var exists: Bool {
|
var exists: Bool {
|
||||||
return FileManager.default.fileExists(atPath: string)
|
return FileManager.default.fileExists(atPath: string)
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public extension Pathish {
|
|||||||
Returns the filename extension of this path.
|
Returns the filename extension of this path.
|
||||||
- Remark: If there is no extension returns "".
|
- Remark: If there is no extension returns "".
|
||||||
- Remark: If the filename ends with any number of ".", returns "".
|
- Remark: If the filename ends with any number of ".", returns "".
|
||||||
- Note: We special case eg. `foo.tar.gz`.
|
- Note: We special case eg. `foo.tar.gz`—there are a limited number of these specializations, feel free to PR more.
|
||||||
*/
|
*/
|
||||||
@inlinable
|
@inlinable
|
||||||
var `extension`: String {
|
var `extension`: String {
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ extension PathTests {
|
|||||||
do {
|
do {
|
||||||
let finder = tmpdir.find().depth(max: 1)
|
let finder = tmpdir.find().depth(max: 1)
|
||||||
XCTAssertEqual(finder.depth, 1...1)
|
XCTAssertEqual(finder.depth, 1...1)
|
||||||
#if !os(Linux) || swift(>=5)
|
#if !os(Linux) || swift(>=5)
|
||||||
XCTAssertEqual(Set(finder), Set([tmpdir.a, tmpdir.b, tmpdir.c].map(Path.init)))
|
XCTAssertEqual(Set(finder), Set([tmpdir.a, tmpdir.b, tmpdir.c].map(Path.init)))
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
let finder = tmpdir.find().depth(max: 0)
|
let finder = tmpdir.find().depth(max: 0)
|
||||||
XCTAssertEqual(finder.depth, 0...0)
|
XCTAssertEqual(finder.depth, 0...0)
|
||||||
#if !os(Linux) || swift(>=5)
|
#if !os(Linux) || swift(>=5)
|
||||||
XCTAssertEqual(Set(finder), Set())
|
XCTAssertEqual(Set(finder), Set())
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,16 +34,20 @@ extension PathTests {
|
|||||||
do {
|
do {
|
||||||
let finder = tmpdir.find().depth(max: 2)
|
let finder = tmpdir.find().depth(max: 2)
|
||||||
XCTAssertEqual(finder.depth, 1...2)
|
XCTAssertEqual(finder.depth, 1...2)
|
||||||
|
#if !os(Linux) || swift(>=5)
|
||||||
XCTAssertEqual(
|
XCTAssertEqual(
|
||||||
Set(finder),
|
Set(finder),
|
||||||
Set([tmpdir.a, tmpdir.b, tmpdir.b.d, tmpdir.b.c].map(Path.init)))
|
Set([tmpdir.a, tmpdir.b, tmpdir.b.d, tmpdir.b.c].map(Path.init)))
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
let finder = tmpdir.find().depth(max: 3)
|
let finder = tmpdir.find().depth(max: 3)
|
||||||
XCTAssertEqual(finder.depth, 1...3)
|
XCTAssertEqual(finder.depth, 1...3)
|
||||||
|
#if !os(Linux) || swift(>=5)
|
||||||
XCTAssertEqual(
|
XCTAssertEqual(
|
||||||
Set(finder),
|
Set(finder),
|
||||||
Set([tmpdir.a, tmpdir.b, tmpdir.b.d, tmpdir.b.c, tmpdir.b.d.e].map(Path.init)))
|
Set([tmpdir.a, tmpdir.b, tmpdir.b.d, tmpdir.b.c, tmpdir.b.d.e].map(Path.init)))
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,7 +66,7 @@ extension PathTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFindKinds() throws {
|
func testFindTypes() throws {
|
||||||
try Path.mktemp { tmpdir in
|
try Path.mktemp { tmpdir in
|
||||||
try tmpdir.foo.mkdir()
|
try tmpdir.foo.mkdir()
|
||||||
try tmpdir.bar.touch()
|
try tmpdir.bar.touch()
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ extension PathTests {
|
|||||||
("testFileReference", testFileReference),
|
("testFileReference", testFileReference),
|
||||||
("testFilesystemAttributes", testFilesystemAttributes),
|
("testFilesystemAttributes", testFilesystemAttributes),
|
||||||
("testFindExtension", testFindExtension),
|
("testFindExtension", testFindExtension),
|
||||||
("testFindKinds", testFindKinds),
|
|
||||||
("testFindMaxDepth0", testFindMaxDepth0),
|
|
||||||
("testFindMaxDepth1", testFindMaxDepth1),
|
("testFindMaxDepth1", testFindMaxDepth1),
|
||||||
|
("testFindMaxDepth2", testFindMaxDepth2),
|
||||||
|
("testFindTypes", testFindTypes),
|
||||||
("testFlatMap", testFlatMap),
|
("testFlatMap", testFlatMap),
|
||||||
("testInitializerForRelativePath", testInitializerForRelativePath),
|
("testInitializerForRelativePath", testInitializerForRelativePath),
|
||||||
("testIsDirectory", testIsDirectory),
|
("testIsDirectory", testIsDirectory),
|
||||||
|
|||||||
Reference in New Issue
Block a user