File tree Expand file tree Collapse file tree 6 files changed +40
-49
lines changed Expand file tree Collapse file tree 6 files changed +40
-49
lines changed Original file line number Diff line number Diff line change @@ -272,27 +272,11 @@ struct Init: SwiftlyCommand {
272
272
273
273
// Fish doesn't have path caching, so this might only be needed for bash/zsh
274
274
if pathChanged && !quietShellFollowup && !shell. hasSuffix ( " fish " ) {
275
- await ctx. print ( """
276
- Your shell caches items on your path for better performance. Swiftly has added
277
- items to your path that may not get picked up right away. You can update your
278
- shell's environment by running
279
-
280
- hash -r
281
-
282
- or restarting your shell.
283
-
284
- """ )
275
+ await ctx. print ( Messages . refreshShell)
285
276
}
286
277
287
278
if let postInstall {
288
- await ctx. print ( """
289
- There are some dependencies that should be installed before using this toolchain.
290
- You can run the following script as the system administrator (e.g. root) to prepare
291
- your system:
292
-
293
- \( postInstall)
294
-
295
- """ )
279
+ await ctx. print ( Messages . postInstall ( postInstall) )
296
280
}
297
281
}
298
282
}
Original file line number Diff line number Diff line change @@ -106,37 +106,20 @@ struct Install: SwiftlyCommand {
106
106
107
107
// Fish doesn't cache its path, so this instruction is not necessary.
108
108
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)
119
110
}
120
111
121
112
if let postInstallScript {
122
113
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) )
132
115
}
133
116
134
117
try Data ( postInstallScript. utf8) . write (
135
118
to: URL ( fileURLWithPath: postInstallFile) , options: . atomic
136
119
)
137
120
}
138
- }
139
-
121
+ }
122
+
140
123
public static func setupProxies(
141
124
_ ctx: SwiftlyCoreContext ,
142
125
version: ToolchainVersion ,
Original file line number Diff line number Diff line change @@ -32,11 +32,15 @@ struct Link: SwiftlyCommand {
32
32
config: & config
33
33
)
34
34
35
- let _ = try await Install . setupProxies (
35
+ let pathChanged = try await Install . setupProxies (
36
36
ctx,
37
37
version: toolchainVersion,
38
38
verbose: self . root. verbose,
39
39
assumeYes: self . root. assumeYes
40
40
)
41
+
42
+ if pathChanged {
43
+ await ctx. print ( Messages . refreshShell)
44
+ }
41
45
}
42
46
}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ struct Unlink: SwiftlyCommand {
27
27
mutating func run( _ ctx: SwiftlyCoreContext ) async throws {
28
28
try validateSwiftly ( ctx)
29
29
30
+ var pathChanged = false
30
31
if let proxyTo = try ? Swiftly . currentPlatform. findSwiftlyBin ( ctx) {
31
32
let swiftlyBinDir = Swiftly . currentPlatform. swiftlyBinDir ( ctx)
32
33
let swiftlyBinDirContents = ( try ? FileManager . default. contentsOfDirectory ( atPath: swiftlyBinDir. path) ) ?? [ String] ( )
@@ -43,8 +44,13 @@ struct Unlink: SwiftlyCommand {
43
44
44
45
if proxy. fileExists ( ) {
45
46
try FileManager . default. removeItem ( at: proxy)
47
+ pathChanged = true
46
48
}
47
49
}
48
50
}
51
+
52
+ if pathChanged {
53
+ await ctx. print ( Messages . refreshShell)
54
+ }
49
55
}
50
56
}
Original file line number Diff line number Diff line change @@ -141,15 +141,7 @@ struct Update: SwiftlyCommand {
141
141
}
142
142
143
143
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)
153
145
}
154
146
}
155
147
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