Fixed nushell error when creating new folder when uploading wsl-remote-server (#40432)

kingananas20 created

Closes #40269 

Release Notes:

- N/A

Change summary

crates/remote/src/transport/wsl.rs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

Detailed changes

crates/remote/src/transport/wsl.rs 🔗

@@ -206,7 +206,7 @@ impl WslRemoteConnection {
                 ))
                 .unwrap(),
             );
-            self.upload_file(&remote_server_path, &tmp_path, delegate, cx)
+            self.upload_file(&remote_server_path, &tmp_path, delegate, &shell, cx)
                 .await?;
             self.extract_and_install(&tmp_path, &dst_path, delegate, cx)
                 .await?;
@@ -239,7 +239,8 @@ impl WslRemoteConnection {
         );
         let tmp_path = RelPath::unix(&tmp_path).unwrap();
 
-        self.upload_file(&src_path, &tmp_path, delegate, cx).await?;
+        self.upload_file(&src_path, &tmp_path, delegate, &shell, cx)
+            .await?;
         self.extract_and_install(&tmp_path, &dst_path, delegate, cx)
             .await?;
 
@@ -251,14 +252,19 @@ impl WslRemoteConnection {
         src_path: &Path,
         dst_path: &RelPath,
         delegate: &Arc<dyn RemoteClientDelegate>,
+        shell: &ShellKind,
         cx: &mut AsyncApp,
     ) -> Result<()> {
         delegate.set_status(Some("Uploading remote server to WSL"), cx);
 
         if let Some(parent) = dst_path.parent() {
-            self.run_wsl_command("mkdir", &["-p", &parent.display(PathStyle::Posix)])
-                .await
-                .map_err(|e| anyhow!("Failed to create directory when uploading file: {}", e))?;
+            let parent = parent.display(PathStyle::Posix);
+            if *shell == ShellKind::Nushell {
+                self.run_wsl_command("mkdir", &[&parent]).await
+            } else {
+                self.run_wsl_command("mkdir", &["-p", &parent]).await
+            }
+            .map_err(|e| anyhow!("Failed to create directory when uploading file: {}", e))?;
         }
 
         let t0 = Instant::now();