From 294563d8dc89ad7c77d50dcfca75f7a09cbc1205 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Mon, 4 Jan 2021 11:01:13 +0800 Subject: [PATCH] chore(build): upgrade ureq to 2.0 --- build/Cargo.toml | 4 ++-- build/src/windows.rs | 19 ++++++++++--------- napi/Cargo.toml | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/build/Cargo.toml b/build/Cargo.toml index 6315b305..4e9913a9 100644 --- a/build/Cargo.toml +++ b/build/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://github.com/napi-rs/napi-rs" version = "1.0.0" [dependencies] -cfg-if = "1.0" +cfg-if = "1" [target.'cfg(windows)'.dependencies] -ureq = {version = "1.5.0", default-features = false, features = ["native-tls"]} +ureq = "2" diff --git a/build/src/windows.rs b/build/src/windows.rs index 08dd623c..a8cf1b5e 100644 --- a/build/src/windows.rs +++ b/build/src/windows.rs @@ -23,16 +23,17 @@ fn download_node_lib(dist_url: &str, version: &str, arch: &str) -> Vec { arch = arch ); - let response = ureq::get(&url).call(); - if let Some(error) = response.synthetic_error() { - panic!("Failed to download node.lib: {:#?}", error); + match ureq::get(&url).call() { + Ok(response) => { + let mut reader = response.into_reader(); + let mut bytes = vec![]; + reader.read_to_end(&mut bytes).unwrap(); + bytes + } + Err(error) => { + panic!("Failed to download node.lib: {:#?}", error); + } } - - let mut reader = response.into_reader(); - let mut bytes = vec![]; - reader.read_to_end(&mut bytes).unwrap(); - - bytes } pub fn setup() { diff --git a/napi/Cargo.toml b/napi/Cargo.toml index ccc5e80d..9c78cc7b 100644 --- a/napi/Cargo.toml +++ b/napi/Cargo.toml @@ -26,7 +26,7 @@ tokio_rt = ["futures", "tokio", "once_cell"] napi-sys = {version = "1", path = "../sys"} [target.'cfg(windows)'.dependencies] -winapi = "0.3.9" +winapi = {version = "0.3.9", features = ["winuser", "minwindef", "ntdef", "libloaderapi"]} [dependencies.encoding_rs] optional = true