-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xcparse should give better error when xcresult path leads to non-xcre…
…sult (#47) Change Description: This fixes #40 by putting an explicit check to see if the xcresult path exists as a directory with an Info.plist before attempting any xcresulttool attempts. If the path does not pass, an error is given to the user highlighting the input path they gave that does not appear to be an xcresult. Test Plan/Testing Performed: Added unit tests to the commands to confirm the error will get shown.
- Loading branch information
1 parent
67f91cc
commit 936c151
Showing
5 changed files
with
159 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// String+ASCII.swift | ||
// | ||
// | ||
// Created by Alexander Botkin on 7/5/20. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension String { | ||
func lossyASCIIString() -> String? { | ||
let string = self.precomposedStringWithCanonicalMapping | ||
guard let lossyASCIIData = string.data(using: .ascii, allowLossyConversion: true) else { | ||
return nil | ||
} | ||
guard let lossyASCIIString = String(data: lossyASCIIData, encoding: .ascii) else { | ||
return nil | ||
} | ||
return lossyASCIIString | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// URL+Directory.swift | ||
// | ||
// | ||
// Created by Alexander Botkin on 7/5/20. | ||
// | ||
|
||
import Foundation | ||
|
||
public extension Foundation.URL { | ||
func fileExistsAsDirectory() -> Bool { | ||
var isDirectory: ObjCBool = false | ||
if FileManager.default.fileExists(atPath: self.path, isDirectory: &isDirectory) { | ||
if isDirectory.boolValue { | ||
return true // Exists as a directory | ||
} else { | ||
return false // Exists as a file | ||
} | ||
} else { | ||
return false // Does not exist | ||
} | ||
} | ||
|
||
func createDirectoryIfNecessary(createIntermediates: Bool = false, console: Console = Console()) -> Bool { | ||
var isDirectory: ObjCBool = false | ||
if FileManager.default.fileExists(atPath: self.path, isDirectory: &isDirectory) { | ||
if isDirectory.boolValue { | ||
// Directory already exists, do nothing | ||
return true | ||
} else { | ||
console.writeMessage("\(self) is not a directory", to: .error) | ||
return false | ||
} | ||
} else { | ||
if createIntermediates == true { | ||
console.shellCommand(["mkdir", "-p", self.path]) | ||
} else { | ||
console.shellCommand(["mkdir", self.path]) | ||
} | ||
} | ||
|
||
return self.fileExistsAsDirectory() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters