windows: Fix tailwind-language-server (#17778)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run

Closes #17741

I'm not sure why, but ever since `tailwind` was upgraded to `0.24`,
there have been occasional errors indicating that the `.ps1` file could
not be found. After reviewing the `.ps1` script, it appears that it
simply starts the server using `node`. This PR directly using the method
from the script to start the server with `node`.


Co-authored-by: Anay <me@anayparaswani.dev>


Release Notes:

- N/A

---------

Co-authored-by: Anay <me@anayparaswani.dev>
This commit is contained in:
Junkui Zhang 2024-09-18 11:59:19 +08:00 committed by GitHub
parent 8e30229ec9
commit 2699fa8d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -18,20 +18,15 @@ use std::{
use util::{maybe, ResultExt};
#[cfg(target_os = "windows")]
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server.ps1";
const SERVER_PATH: &str =
"node_modules/@tailwindcss/language-server/bin/tailwindcss-language-server";
#[cfg(not(target_os = "windows"))]
const SERVER_PATH: &str = "node_modules/.bin/tailwindcss-language-server";
#[cfg(not(target_os = "windows"))]
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
vec![server_path.into(), "--stdio".into()]
}
#[cfg(target_os = "windows")]
fn server_binary_arguments(server_path: &Path) -> Vec<OsString> {
vec!["-File".into(), server_path.into(), "--stdio".into()]
}
pub struct TailwindLspAdapter {
node: Arc<dyn NodeRuntime>,
}
@ -114,26 +109,11 @@ impl LspAdapter for TailwindLspAdapter {
.await?;
}
#[cfg(target_os = "windows")]
{
let env_path = self.node.node_environment_path().await?;
let mut env = HashMap::default();
env.insert("PATH".to_string(), env_path.to_string_lossy().to_string());
Ok(LanguageServerBinary {
path: "powershell.exe".into(),
env: Some(env),
arguments: server_binary_arguments(&server_path),
})
}
#[cfg(not(target_os = "windows"))]
{
Ok(LanguageServerBinary {
path: self.node.binary_path().await?,
env: None,
arguments: server_binary_arguments(&server_path),
})
}
Ok(LanguageServerBinary {
path: self.node.binary_path().await?,
env: None,
arguments: server_binary_arguments(&server_path),
})
}
async fn cached_server_binary(