diff options
Diffstat (limited to 'cli/tools/fmt.rs')
-rw-r--r-- | cli/tools/fmt.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index b9525b7b2..92facc7ec 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -191,13 +191,13 @@ fn format_markdown( rest => rest, }; + let fake_filename = + PathBuf::from(format!("deno_fmt_stdin.{extension}")); if matches!(extension, "json" | "jsonc") { let mut json_config = get_resolved_json_config(fmt_options); json_config.line_width = line_width; - dprint_plugin_json::format_text(text, &json_config) + dprint_plugin_json::format_text(&fake_filename, text, &json_config) } else { - let fake_filename = - PathBuf::from(format!("deno_fmt_stdin.{extension}")); let mut codeblock_config = get_resolved_typescript_config(fmt_options); codeblock_config.line_width = line_width; @@ -218,11 +218,12 @@ fn format_markdown( /// of configuration builder of <https://github.com/dprint/dprint-plugin-json>. /// See <https://github.com/dprint/dprint-plugin-json/blob/cfa1052dbfa0b54eb3d814318034cdc514c813d7/src/configuration/builder.rs#L87> for configuration. pub fn format_json( + file_path: &Path, file_text: &str, fmt_options: &FmtOptionsConfig, ) -> Result<Option<String>, AnyError> { let config = get_resolved_json_config(fmt_options); - dprint_plugin_json::format_text(file_text, &config) + dprint_plugin_json::format_text(file_path, file_text, &config) } /// Formats a single TS, TSX, JS, JSX, JSONC, JSON, or MD file. @@ -238,7 +239,7 @@ pub fn format_file( ) { format_markdown(file_text, fmt_options) } else if matches!(ext.as_str(), "json" | "jsonc") { - format_json(file_text, fmt_options) + format_json(file_path, file_text, fmt_options) } else { let config = get_resolved_typescript_config(fmt_options); dprint_plugin_typescript::format_text(file_path, file_text, &config) |