mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Initialize prettier_server.js wrapper along with default prettier
This commit is contained in:
parent
010bb73ac2
commit
dca93fb177
7 changed files with 7 additions and 39 deletions
1
crates/prettier/prettier_server/.gitignore
vendored
1
crates/prettier/prettier_server/.gitignore
vendored
|
@ -1 +0,0 @@
|
|||
node_modules/
|
|
@ -1,7 +0,0 @@
|
|||
{
|
||||
"languages": {
|
||||
"JavaScript": {
|
||||
"tab_size": 4
|
||||
}
|
||||
}
|
||||
}
|
12
crates/prettier/prettier_server/package-lock.json
generated
12
crates/prettier/prettier_server/package-lock.json
generated
|
@ -1,12 +0,0 @@
|
|||
{
|
||||
"name": "prettier_server",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "prettier_server",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"name": "prettier_server",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"start": "node src/index.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Zed Industries",
|
||||
"dev-dependencies": {
|
||||
"prettier": "^3.0"
|
||||
}
|
||||
}
|
|
@ -18,6 +18,8 @@ pub struct LocateStart {
|
|||
pub starting_path: Arc<Path>,
|
||||
}
|
||||
|
||||
pub const PRETTIER_SERVER_JS: &str = include_str!("./prettier_server.js");
|
||||
|
||||
impl Prettier {
|
||||
// This was taken from the prettier-vscode extension.
|
||||
pub const CONFIG_FILE_NAMES: &'static [&'static str] = &[
|
||||
|
|
|
@ -79,7 +79,7 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
use terminals::Terminals;
|
||||
use text::Anchor;
|
||||
use text::{Anchor, LineEnding, Rope};
|
||||
use util::{
|
||||
debug_panic, defer,
|
||||
http::HttpClient,
|
||||
|
@ -8350,10 +8350,10 @@ impl Project {
|
|||
let fs = Arc::clone(&self.fs);
|
||||
cx.background()
|
||||
.spawn(async move {
|
||||
let prettier_dir_metadata = fs.metadata(default_prettier_dir).await.with_context(|| format!("fetching FS metadata for prettier default dir {default_prettier_dir:?}"))?;
|
||||
if prettier_dir_metadata.is_none() {
|
||||
fs.create_dir(default_prettier_dir).await.with_context(|| format!("creating prettier default dir {default_prettier_dir:?}"))?;
|
||||
}
|
||||
let prettier_wrapper_path = default_prettier_dir.join("prettier_server.js");
|
||||
// method creates parent directory if it doesn't exist
|
||||
fs.save(&prettier_wrapper_path, &Rope::from(prettier::PRETTIER_SERVER_JS), LineEnding::Unix).await
|
||||
.with_context(|| format!("writing prettier_server.js file at {prettier_wrapper_path:?}"))?;
|
||||
|
||||
let packages_to_versions = future::try_join_all(
|
||||
prettier_plugins
|
||||
|
|
Loading…
Reference in a new issue