@@ -595,7 +595,7 @@ public final class XcodeInstaller {
595595 }
596596 }
597597
598- public func uninstallXcode( _ versionString: String , directory: Path ) -> Promise < Void > {
598+ public func uninstallXcode( _ versionString: String , directory: Path , deleteApp : Bool ) -> Promise < Void > {
599599 return firstly { ( ) -> Promise < InstalledXcode > in
600600 guard let version = Version ( xcodeVersion: versionString) else {
601601 Current . logging. log ( Error . invalidVersion ( versionString) . legibleLocalizedDescription)
@@ -609,11 +609,17 @@ public final class XcodeInstaller {
609609
610610 return Promise . value ( installedXcode)
611611 }
612- . map { ( $0, try Current . files. trashItem ( at: $0. path. url) ) }
613- . then { ( installedXcode, trashURL) -> Promise < ( InstalledXcode , URL ) > in
612+ . map { installedXcode -> ( InstalledXcode , URL ? ) in
613+ if deleteApp {
614+ try Current . files. removeItem ( at: installedXcode. path. url)
615+ return ( installedXcode, nil )
616+ }
617+ return ( installedXcode, try Current . files. trashItem ( at: installedXcode. path. url) )
618+ }
619+ . then { ( installedXcode, trashURL) -> Promise < ( InstalledXcode , URL ? ) > in
614620 // If we just uninstalled the selected Xcode, try to select the latest installed version so things don't accidentally break
615621 Current . shell. xcodeSelectPrintPath ( )
616- . then { output -> Promise < ( InstalledXcode , URL ) > in
622+ . then { output -> Promise < ( InstalledXcode , URL ? ) > in
617623 if output. out. hasPrefix ( installedXcode. path. string) ,
618624 let latestInstalledXcode = Current . files. installedXcodes ( directory) . sorted ( by: { $0. version < $1. version } ) . last {
619625 return selectXcodeAtPath ( latestInstalledXcode. path. string)
@@ -628,7 +634,12 @@ public final class XcodeInstaller {
628634 }
629635 }
630636 . done { ( installedXcode, trashURL) in
631- Current . logging. log ( " Xcode \( installedXcode. version. appleDescription) moved to Trash: \( trashURL. path) " . green)
637+ if let trashURL = trashURL {
638+ Current . logging. log ( " Xcode \( installedXcode. version. appleDescription) moved to Trash: \( trashURL. path) " . green)
639+ }
640+ else {
641+ Current . logging. log ( " Xcode \( installedXcode. version. appleDescription) deleted " . green)
642+ }
632643 Current . shell. exit ( 0 )
633644 }
634645 }
0 commit comments