Skip to content

Commit

Permalink
fix wasm compat
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanapol Prucksakorn committed Aug 13, 2023
1 parent 1acbc29 commit 4a88c76
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
10 changes: 3 additions & 7 deletions crates/taplo-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
};
use taplo_common::{
config::Config,
environment::Environment,
schema::Schemas,
util::{get_reqwest_client, Normalize},
};
use taplo_common::{config::Config, environment::Environment, schema::Schemas, util::Normalize};

pub mod args;
pub mod commands;
Expand All @@ -26,7 +21,8 @@ pub struct Taplo<E: Environment> {
impl<E: Environment> Taplo<E> {
pub fn new(env: E) -> Self {
#[cfg(not(target_arch = "wasm32"))]
let http = get_reqwest_client(std::time::Duration::from_secs(5)).unwrap();
let http =
taplo_common::util::get_reqwest_client(std::time::Duration::from_secs(5)).unwrap();

#[cfg(target_arch = "wasm32")]
let http = reqwest::Client::default();
Expand Down
1 change: 1 addition & 0 deletions crates/taplo-common/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub(crate) fn normalize_str(s: &str) -> Cow<str> {
}
}

#[cfg(not(target_arch = "wasm32"))]
#[tracing::instrument]
pub fn get_reqwest_client(timeout: std::time::Duration) -> Result<reqwest::Client, reqwest::Error> {
fn get_cert(path: impl AsRef<Path>) -> Result<reqwest::Certificate, anyhow::Error> {
Expand Down
3 changes: 1 addition & 2 deletions crates/taplo-lsp/src/world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use taplo_common::{
associations::{priority, source, AssociationRule, SchemaAssociation},
Schemas,
},
util::get_reqwest_client,
AsyncRwLock, HashMap, IndexMap,
};

Expand Down Expand Up @@ -125,7 +124,7 @@ impl<E: Environment> WorkspaceState<E> {

#[cfg(not(target_arch = "wasm32"))]
{
client = get_reqwest_client(Duration::from_secs(10)).unwrap();
client = taplo_common::util::get_reqwest_client(Duration::from_secs(10)).unwrap();
}

Self {
Expand Down

0 comments on commit 4a88c76

Please sign in to comment.