File tree Expand file tree Collapse file tree 6 files changed +39
-39
lines changed Expand file tree Collapse file tree 6 files changed +39
-39
lines changed Original file line number Diff line number Diff line change @@ -298,14 +298,7 @@ struct Init: SwiftlyCommand {
298298 }
299299
300300 if let postInstall {
301- await ctx. print ( """
302- There are some dependencies that should be installed before using this toolchain.
303- You can run the following script as the system administrator (e.g. root) to prepare
304- your system:
305-
306- \( postInstall)
307-
308- """ )
301+ await ctx. print ( Messages . postInstall ( postInstall) )
309302 }
310303 }
311304}
Original file line number Diff line number Diff line change @@ -106,37 +106,20 @@ struct Install: SwiftlyCommand {
106106
107107 // Fish doesn't cache its path, so this instruction is not necessary.
108108 if pathChanged && !shell. hasSuffix ( " fish " ) {
109- await ctx. print (
110- """
111- NOTE: Swiftly has updated some elements in your path and your shell may not yet be
112- aware of the changes. You can update your shell's environment by running
113-
114- hash -r
115-
116- or restarting your shell.
117-
118- """ )
109+ await ctx. print ( Messages . refreshShell)
119110 }
120111
121112 if let postInstallScript {
122113 guard let postInstallFile = self . postInstallFile else {
123- throw SwiftlyError (
124- message: """
125-
126- There are some dependencies that should be installed before using this toolchain.
127- You can run the following script as the system administrator (e.g. root) to prepare
128- your system:
129-
130- \( postInstallScript)
131- """ )
114+ throw SwiftlyError ( message: Messages . postInstall ( postInstallScript) )
132115 }
133116
134117 try Data ( postInstallScript. utf8) . write (
135118 to: URL ( fileURLWithPath: postInstallFile) , options: . atomic
136119 )
137120 }
138- }
139-
121+ }
122+
140123 public static func setupProxies(
141124 _ ctx: SwiftlyCoreContext ,
142125 version: ToolchainVersion ,
Original file line number Diff line number Diff line change @@ -32,11 +32,15 @@ struct Link: SwiftlyCommand {
3232 config: & config
3333 )
3434
35- let _ = try await Install . setupProxies (
35+ let pathChanged = try await Install . setupProxies (
3636 ctx,
3737 version: toolchainVersion,
3838 verbose: self . root. verbose,
3939 assumeYes: self . root. assumeYes
4040 )
41+
42+ if pathChanged {
43+ await ctx. print ( Messages . refreshShell)
44+ }
4145 }
4246}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ struct Unlink: SwiftlyCommand {
2727 mutating func run( _ ctx: SwiftlyCoreContext ) async throws {
2828 try validateSwiftly ( ctx)
2929
30+ var pathChanged = false
3031 if let proxyTo = try ? Swiftly . currentPlatform. findSwiftlyBin ( ctx) {
3132 let swiftlyBinDir = Swiftly . currentPlatform. swiftlyBinDir ( ctx)
3233 let swiftlyBinDirContents = ( try ? FileManager . default. contentsOfDirectory ( atPath: swiftlyBinDir. path) ) ?? [ String] ( )
@@ -43,8 +44,13 @@ struct Unlink: SwiftlyCommand {
4344
4445 if proxy. fileExists ( ) {
4546 try FileManager . default. removeItem ( at: proxy)
47+ pathChanged = true
4648 }
4749 }
4850 }
51+
52+ if pathChanged {
53+ await ctx. print ( Messages . refreshShell)
54+ }
4955 }
5056}
Original file line number Diff line number Diff line change @@ -141,15 +141,7 @@ struct Update: SwiftlyCommand {
141141 }
142142
143143 if pathChanged {
144- await ctx. print ( """
145- NOTE: Swiftly has updated some elements in your path and your shell may not yet be
146- aware of the changes. You can update your shell's environment by running
147-
148- hash -r
149-
150- or restarting your shell.
151-
152- """ )
144+ await ctx. print ( Messages . refreshShell)
153145 }
154146 }
155147
Original file line number Diff line number Diff line change 1+ public struct Messages {
2+ public static let refreshShell = """
3+ NOTE: Swiftly has updated some elements in your path and your shell may not yet be
4+ aware of the changes. You can update your shell's environment by running
5+
6+ hash -r
7+
8+ or restarting your shell.
9+
10+ """
11+
12+ public static func postInstall( _ message: String ) -> String {
13+ """
14+ There are some dependencies that should be installed before using this toolchain.
15+ You can run the following script as the system administrator (e.g. root) to prepare
16+ your system:
17+
18+ \( message)
19+
20+ """
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments