From fbd96078447b02b976ad4ff2472c7cfa5163035c Mon Sep 17 00:00:00 2001 From: uhyo Date: Sat, 28 Dec 2024 13:11:12 +0900 Subject: [PATCH] fix: use escape_default() when emitting JS string literal from Rust --- crates/cli/src/schema_loader.rs | 3 +-- crates/config-file/src/node.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/cli/src/schema_loader.rs b/crates/cli/src/schema_loader.rs index 8ec61a2..2a5000c 100644 --- a/crates/cli/src/schema_loader.rs +++ b/crates/cli/src/schema_loader.rs @@ -26,12 +26,11 @@ pub async fn load_schema_js(path: &Path) -> io::Result { let res_json = run_node(&format!( r#" import {{ loadSchemaJs }} from "@nitrogql/core"; -import {{ stdout }} from "process"; const result = await loadSchemaJs("{}"); export default result; "#, - path.display() + path.to_string_lossy().escape_default() )) .await?; let parsed: LoadSchemaJsResult = serde_yaml::from_str(&res_json).expect("failed to parse JSON"); diff --git a/crates/config-file/src/node.rs b/crates/config-file/src/node.rs index 492d366..7dbc361 100644 --- a/crates/config-file/src/node.rs +++ b/crates/config-file/src/node.rs @@ -120,7 +120,7 @@ import config from "{}"; import {{ stdout }} from "process"; export default config?.default ?? config; "#, - path.display() + path.to_string_lossy().escape_default() )) .await }