WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 1409a24

Browse files
committed
refactor(xtask): handle some errors
1 parent a84c795 commit 1409a24

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

xtask/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ fn generate_file(file: &str, token_stream: proc_macro2::TokenStream) {
2525

2626
pub fn parse_caniuse_global() -> Result<Caniuse> {
2727
let path = root().join("node_modules/caniuse-db/fulldata-json/data-2.0.json");
28-
Ok(serde_json::from_slice(&fs::read(path)?)?)
28+
let json = fs::read_to_string(path)?;
29+
Ok(serde_json::from_str(&json)?)
2930
}
3031

3132
#[derive(Deserialize)]

xtask/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{fs, process::Command};
33
use anyhow::Result;
44

55
fn main() -> Result<()> {
6-
let dir = project_root::get_project_root().unwrap().join("src/generated");
6+
let dir = project_root::get_project_root()?.join("src/generated");
77
let _ = fs::remove_dir_all(&dir);
88
let _ = fs::create_dir(&dir);
99

@@ -18,7 +18,7 @@ fn main() -> Result<()> {
1818
xtask::caniuse_browsers::build_caniuse_browsers(&caniuse)?;
1919
xtask::caniuse_region_matching::build_caniuse_region_matching(&caniuse)?;
2020

21-
Command::new("cargo").arg("fmt").status().unwrap();
21+
Command::new("cargo").arg("fmt").status()?;
2222

2323
Ok(())
2424
}

0 commit comments

Comments
 (0)