fix linting directories ending in .swift

This commit is contained in:
JP Simard
2017-01-06 11:33:21 -08:00
parent 4d1bf35bcf
commit 36b1ea0ba4
2 changed files with 18 additions and 1 deletions
+3
View File
@@ -124,6 +124,9 @@
* Fix `variable_name` and `type_name` rules on Linux.
[Marcelo Fabri](https://github.com/marcelofabri)
* Fix linting directories with names ending with `.swift`.
[JP Simard](https://github.com/jpsim)
## 0.15.0: Hand Washable Holiday Linens 🎄
##### Breaking
@@ -9,6 +9,20 @@
import Foundation
import SourceKittenFramework
extension String {
fileprivate var isFile: Bool {
var isDirectoryObjC: ObjCBool = false
if FileManager.default.fileExists(atPath: self, isDirectory: &isDirectoryObjC) {
#if os(Linux)
return !isDirectoryObjC
#else
return !isDirectoryObjC.boolValue
#endif
}
return false
}
}
private let fileManager = FileManager.default
private enum ConfigurationKey: String {
@@ -170,7 +184,7 @@ public struct Configuration: Equatable {
public func lintablePathsForPath(_ path: String,
fileManager: LintableFileManager = fileManager) -> [String] {
// If path is a Swift file, skip filtering with excluded/included paths
if path.bridge().isSwiftFile() {
if path.bridge().isSwiftFile() && path.isFile {
return [path]
}
let pathsForPath = included.isEmpty ? fileManager.filesToLintAtPath(path, rootDirectory: nil) : []