Compare commits

..

10 Commits
0.4.0 ... 0.4.2

Author SHA1 Message Date
Max Howell
aac81b85a4 Merge pull request #8 from mxcl/better-deploy
Better deploy
2019-01-20 18:53:11 -05:00
Max Howell
3644124a36 Fix testing on tvOS/iOS 2019-01-20 18:44:24 -05:00
Max Howell
ca4ac3ec8f Fix stage types in .travis.yml 2019-01-20 17:33:56 -05:00
Max Howell
920f007660 Fix Linux testEnumerationSkippingHiddenFiles() 2019-01-20 17:32:39 -05:00
Max Howell
751b855a26 Pretest that fails if Linux tests aren't current 2019-01-20 17:25:46 -05:00
Max Howell
c0e5023632 Better deployment of Jazzy and Pods 2019-01-20 17:13:03 -05:00
Max Howell
e0c62108e8 Update Linux tests 2019-01-20 16:30:02 -05:00
Max Howell
5cc2fcbf30 Tag 0.4.1 2019-01-20 16:26:22 -05:00
Max Howell
7595c601e8 Attempt custom Jazzy index/contents 2019-01-20 16:24:06 -05:00
Luciano Almeida
d8ea357459 Adding ls -a like functionality to Path.ls() 2019-01-20 16:23:40 -05:00
7 changed files with 109 additions and 44 deletions

View File

@@ -2,6 +2,7 @@
if: type != push OR branch = master OR branch =~ /^\d+\.\d+(\.\d+)?(-\S*)?$/ if: type != push OR branch = master OR branch =~ /^\d+\.\d+(\.\d+)?(-\S*)?$/
stages: stages:
- name: pretest
- name: test - name: test
- name: deploy - name: deploy
if: branch =~ ^\d+\.\d+\.\d+$ if: branch =~ ^\d+\.\d+\.\d+$
@@ -34,7 +35,6 @@ jobs:
-destination 'platform=watchOS Simulator,OS=latest,name=Apple Watch Series 4 - 40mm' \ -destination 'platform=watchOS Simulator,OS=latest,name=Apple Watch Series 4 - 40mm' \
build | xcpretty build | xcpretty
- env: SWIFT_VERSION=4.2.1 - env: SWIFT_VERSION=4.2.1
os: linux os: linux
name: Linux name: Linux
@@ -43,21 +43,34 @@ jobs:
sudo: false sudo: false
install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)" install: eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
script: swift test script: swift test
- stage: pretest
name: Check if Linux tests are up-to-date
install: swift test --generate-linuxmain
script: git diff --exit-code
- <<: *xcodebuild - stage: deploy
stage: deploy
name: Jazzy name: Jazzy
install: gem install jazzy before_install: |
cat << EOF > .jazzy.yaml
module: Path
module_version: $TRAVIS_TAG
custom_categories:
- name: Path
children:
- Path
- /(_:_:)
xcodebuild_arguments:
- UseModernBuildSystem=NO
output: output
github_url: https://github.com/mxcl/Path.swift
EOF
install: |
gem install jazzy
swift package generate-xcodeproj
script: | script: |
jazzy \ jazzy
--no-hide-documentation-coverage \ rm -rf output/docsets
--theme fullwidth \
--output output \
--readme README.md \
--root-url https://mxcl.github.io/Path.swift/ \
--github_url https://github.com/mxcl/Path.swift \
--module Path \
--module-version $TRAVIS_TAG
deploy: deploy:
provider: pages provider: pages
skip-cleanup: true skip-cleanup: true
@@ -66,7 +79,25 @@ jobs:
on: on:
tags: true tags: true
- stage: deploy - name: CocoaPods
name: CocoaPods before_install: |
cat << EOF > Path.swift.podspec
Pod::Spec.new do |s|
s.name = 'Path.swift'
s.version = '$TRAVIS_TAG'
s.summary = 'Delightful, robust file-pathing functions'
s.homepage = 'https://github.com/mxcl/Path.swift'
s.license = { :type => 'Unlicense', :file => 'LICENSE.md' }
s.author = { 'mxcl' => 'mxcl@me.com' }
s.source = { :git => 'https://github.com/mxcl/Path.swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/mxcl'
s.osx.deployment_target = '10.10'
s.ios.deployment_target = '8.0'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '3.0'
s.source_files = 'Sources/*'
s.swift_version = "4.2"
end
EOF
install: gem install cocoapods --pre install: gem install cocoapods --pre
script: pod trunk push --allow-warnings script: pod trunk push --allow-warnings

View File

@@ -1,19 +0,0 @@
Pod::Spec.new do |s|
s.name = 'Path.swift'
s.version = '0.4.0'
s.summary = 'Delightful, robust file-pathing functions'
s.homepage = 'https://github.com/mxcl/Path.swift'
s.license = { :type => 'Unlicense', :file => 'LICENSE.md' }
s.author = { 'mxcl' => 'mxcl@me.com' }
s.source = { :git => 'https://github.com/mxcl/Path.swift.git', :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/mxcl'
s.osx.deployment_target = '10.10'
s.ios.deployment_target = '8.0'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '3.0'
s.source_files = 'Sources/*'
s.swift_version = "4.2"
end

View File

@@ -183,13 +183,13 @@ Path("~foo") // => nil
SwiftPM: SwiftPM:
```swift ```swift
package.append(.package(url: "https://github.com/mxcl/Path.swift", from: "0.4.0")) package.append(.package(url: "https://github.com/mxcl/Path.swift", from: "0.4.1"))
``` ```
CocoaPods: CocoaPods:
```ruby ```ruby
pod 'Path.swift' ~> 0.4.0 pod 'Path.swift' ~> '0.4.1'
``` ```
Please note! We are pre 1.0, thus we can change the API as we like! We will tag Please note! We are pre 1.0, thus we can change the API as we like! We will tag
@@ -208,4 +208,4 @@ https://codebasesaga.com/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-orange.svg [badge-languages]: https://img.shields.io/badge/swift-4.2-orange.svg
[online API documentation]: https://mxcl.github.io/Path.swift/ [online API documentation]: https://mxcl.github.io/Path.swift/Structs/Path.html

View File

@@ -1,14 +1,24 @@
import Foundation import Foundation
public extension Path { public extension Path {
/// same as the `ls` command is shallow /**
func ls() throws -> [Entry] { Same as the `ls -a` command is shallow
let relativePaths = try FileManager.default.contentsOfDirectory(atPath: string) - Parameter includeHiddenFiles: If `true`, hidden files are included in the results. Defaults to `true`.
func convert(relativePath: String) -> Entry { - Important: `includeHiddenFiles` does not work on Linux
let path = self/relativePath */
func ls(includeHiddenFiles: Bool = true) throws -> [Entry] {
var opts = FileManager.DirectoryEnumerationOptions()
#if !os(Linux)
if !includeHiddenFiles {
opts.insert(.skipsHiddenFiles)
}
#endif
let paths = try FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: opts)
func convert(url: URL) -> Entry? {
guard let path = Path(url.path) else { return nil }
return Entry(kind: path.isDirectory ? .directory : .file, path: path) return Entry(kind: path.isDirectory ? .directory : .file, path: path)
} }
return relativePaths.map(convert) return paths.compactMap(convert)
} }
} }

View File

@@ -17,6 +17,7 @@ class PathTests: XCTestCase {
try tmpdir.join("a").mkdir().join("c").touch() try tmpdir.join("a").mkdir().join("c").touch()
try tmpdir.join("b").touch() try tmpdir.join("b").touch()
try tmpdir.join("c").touch() try tmpdir.join("c").touch()
try tmpdir.join(".d").mkdir().join("e").touch()
var paths = Set<String>() var paths = Set<String>()
var dirs = 0 var dirs = 0
@@ -26,8 +27,31 @@ class PathTests: XCTestCase {
} }
paths.insert(entry.path.basename()) paths.insert(entry.path.basename())
} }
XCTAssertEqual(dirs, 2)
XCTAssertEqual(paths, ["a", "b", "c", ".d"])
}
func testEnumerationSkippingHiddenFiles() throws {
#if !os(Linux)
let tmpdir_ = try TemporaryDirectory()
let tmpdir = tmpdir_.path
try tmpdir.join("a").mkdir().join("c").touch()
try tmpdir.join("b").touch()
try tmpdir.join("c").touch()
try tmpdir.join(".d").mkdir().join("e").touch()
var paths = Set<String>()
var dirs = 0
for entry in try tmpdir.ls(includeHiddenFiles: false) {
if entry.kind == .directory {
dirs += 1
}
paths.insert(entry.path.basename())
}
XCTAssertEqual(dirs, 1) XCTAssertEqual(dirs, 1)
XCTAssertEqual(paths, ["a", "b", "c"]) XCTAssertEqual(paths, ["a", "b", "c"])
#endif
} }
func testRelativeTo() { func testRelativeTo() {

View File

@@ -52,3 +52,20 @@ extension Path {
return try body(tmp.path) return try body(tmp.path)
} }
} }
#if !os(macOS) && !os(Linux)
import XCTest
// SwiftPM generates code that is improperly escaped thus we require this to
// compile on iOS & tvOS.
public typealias XCTestCaseEntry = (testCaseClass: XCTestCase.Type, allTests: [(String, (XCTestCase) throws -> Void)])
public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () throws -> Void)]) -> XCTestCaseEntry {
fatalError()
}
public func testCase<T: XCTestCase>(_ allTests: [(String, (T) -> () -> Void)]) -> XCTestCaseEntry {
fatalError()
}
#endif

View File

@@ -6,8 +6,10 @@ extension PathTests {
("testCodable", testCodable), ("testCodable", testCodable),
("testConcatenation", testConcatenation), ("testConcatenation", testConcatenation),
("testEnumeration", testEnumeration), ("testEnumeration", testEnumeration),
("testEnumerationSkippingHiddenFiles", testEnumerationSkippingHiddenFiles),
("testExists", testExists), ("testExists", testExists),
("testIsDirectory", testIsDirectory), ("testIsDirectory", testIsDirectory),
("testJoin", testJoin),
("testMkpathIfExists", testMkpathIfExists), ("testMkpathIfExists", testMkpathIfExists),
("testMktemp", testMktemp), ("testMktemp", testMktemp),
("testRelativePathCodable", testRelativePathCodable), ("testRelativePathCodable", testRelativePathCodable),
@@ -15,7 +17,7 @@ extension PathTests {
] ]
} }
#if os(Linux) #if !os(macOS)
public func __allTests() -> [XCTestCaseEntry] { public func __allTests() -> [XCTestCaseEntry] {
return [ return [
testCase(PathTests.__allTests), testCase(PathTests.__allTests),