Skip to content

Commit

Permalink
chore: update jsonc_parser to 0.20 (denoland#15316)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jul 27, 2022
1 parent b4b4e59 commit ffd74cb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ clap_complete = "=3.1.2"
clap_complete_fig = "=3.1.5"
data-url = "=0.1.1"
dissimilar = "=1.0.3"
dprint-plugin-json = "=0.15.3"
dprint-plugin-json = "=0.15.4"
dprint-plugin-markdown = "=0.13.3"
dprint-plugin-typescript = "=0.71.1"
encoding_rs = "=0.8.31"
Expand All @@ -73,7 +73,7 @@ fancy-regex = "=0.9.0"
http = "=0.2.6"
import_map = "=0.12.1"
indexmap = "1.8.1"
jsonc-parser = { version = "=0.19.0", features = ["serde"] }
jsonc-parser = { version = "=0.20.0", features = ["serde"] }
libc = "=0.2.126"
log = { version = "=0.4.17", features = ["serde"] }
mitata = '=0.0.7'
Expand Down
35 changes: 18 additions & 17 deletions cli/args/config_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,23 +557,24 @@ impl ConfigFile {
text: &str,
specifier: &ModuleSpecifier,
) -> Result<Self, AnyError> {
let jsonc = match jsonc_parser::parse_to_serde_value(text) {
Ok(None) => json!({}),
Ok(Some(value)) if value.is_object() => value,
Ok(Some(_)) => {
return Err(anyhow!(
"config file JSON {:?} should be an object",
specifier,
))
}
Err(e) => {
return Err(anyhow!(
"Unable to parse config file JSON {:?} because of {}",
specifier,
e.to_string()
))
}
};
let jsonc =
match jsonc_parser::parse_to_serde_value(text, &Default::default()) {
Ok(None) => json!({}),
Ok(Some(value)) if value.is_object() => value,
Ok(Some(_)) => {
return Err(anyhow!(
"config file JSON {:?} should be an object",
specifier,
))
}
Err(e) => {
return Err(anyhow!(
"Unable to parse config file JSON {:?} because of {}",
specifier,
e.to_string()
))
}
};
let json: ConfigFileJson = serde_json::from_value(jsonc)?;

Ok(Self {
Expand Down
4 changes: 3 additions & 1 deletion cli/tools/vendor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ fn update_config_text(
) -> Option<String> {
use jsonc_parser::ast::ObjectProp;
use jsonc_parser::ast::Value;
let ast = jsonc_parser::parse_to_ast(text, &Default::default()).ok()?;
let ast =
jsonc_parser::parse_to_ast(text, &Default::default(), &Default::default())
.ok()?;
let obj = match ast.value {
Some(Value::Object(obj)) => obj,
_ => return None, // shouldn't happen, so ignore
Expand Down

0 comments on commit ffd74cb

Please sign in to comment.