@@ -16,23 +16,23 @@ extension CodeEditCLI {
1616 )
1717
1818 func run( ) throws {
19- // Run an apple script to find CodeEdit.app
20- let pathData = try codeEditURLData ( )
19+ // Print the cli version
20+ print ( " CodeEditCLI: \t \( CLI_VERSION) " )
21+
22+ // File URL of CodeEdit.app
23+ let appURL = URL ( fileURLWithPath: " /Applications/CodeEdit.app " )
2124
2225 // Check if there is an Info.plist inside CodeEdit.app
2326 // Then get the version number and print it out
2427 //
2528 // This will fail when CodeEdit.app is not installed
26- if let url = infoPlistUrl ( pathData : pathData ) ,
29+ if let url = infoPlistUrl ( appURL ) ,
2730 let plist = NSDictionary ( contentsOf: url) as? [ String : Any ] ,
2831 let version = plist [ " CFBundleShortVersionString " ] as? String {
2932 print ( " CodeEdit.app: \t \( version) " )
3033 } else {
3134 print ( " CodeEdit.app is not installed. " )
3235 }
33-
34- // Print the cli version
35- print ( " CodeEditCLI: \t \( CLI_VERSION) " )
3636 }
3737
3838 private func codeEditURLData( ) throws -> Data {
@@ -49,11 +49,9 @@ extension CodeEditCLI {
4949 return pipe. fileHandleForReading. readDataToEndOfFile ( )
5050 }
5151
52- private func infoPlistUrl( pathData: Data ) -> URL ? {
53- if let path = String ( data: pathData, encoding: . utf8) {
54- let url = URL ( fileURLWithPath: path. trimmingCharacters ( in: . whitespacesAndNewlines) )
55- . appendingPathComponent ( " Contents " )
56- . appendingPathComponent ( " Info.plist " )
52+ private func infoPlistUrl( _ url: URL ? ) -> URL ? {
53+ if let url = url? . appendingPathComponent ( " Contents " )
54+ . appendingPathComponent ( " Info.plist " ) {
5755 return url
5856 } else {
5957 return nil
0 commit comments