22//!
33use crate :: diagnostics:: StdinDiagnostic ;
44use crate :: execute:: Execution ;
5- use crate :: { CliDiagnostic , CliSession , TEMPORARY_INTERNAL_FILE_NAME , TraversalMode } ;
5+ use crate :: { CliDiagnostic , CliSession , TraversalMode } ;
66use biome_analyze:: RuleCategoriesBuilder ;
77use biome_console:: { ConsoleExt , markup} ;
88use biome_diagnostics:: Diagnostic ;
@@ -15,7 +15,6 @@ use biome_service::workspace::{
1515 ChangeFileParams , CloseFileParams , DropPatternParams , FeaturesBuilder , FileContent ,
1616 FixFileParams , FormatFileParams , OpenFileParams , SupportsFeatureParams ,
1717} ;
18- use camino:: Utf8PathBuf ;
1918use std:: borrow:: Cow ;
2019
2120pub ( crate ) fn run < ' a > (
@@ -30,12 +29,9 @@ pub(crate) fn run<'a>(
3029 let console = & mut * session. app . console ;
3130 let mut version = 0 ;
3231
33- let std_in_file = biome_path
34- . extension ( )
35- . map ( |ext| {
36- BiomePath :: new ( Utf8PathBuf :: from ( TEMPORARY_INTERNAL_FILE_NAME ) . with_extension ( ext) )
37- } )
38- . ok_or_else ( || CliDiagnostic :: from ( StdinDiagnostic :: new_no_extension ( ) ) ) ?;
32+ if biome_path. extension ( ) . is_none ( ) {
33+ return Err ( CliDiagnostic :: from ( StdinDiagnostic :: new_no_extension ( ) ) ) ;
34+ }
3935
4036 if mode. is_format ( ) {
4137 let file_features = workspace. file_features ( SupportsFeatureParams {
@@ -58,14 +54,14 @@ pub(crate) fn run<'a>(
5854 if file_features. supports_format ( ) {
5955 workspace. open_file ( OpenFileParams {
6056 project_key,
61- path : std_in_file . clone ( ) ,
57+ path : biome_path . clone ( ) ,
6258 content : FileContent :: from_client ( content) ,
6359 document_file_source : None ,
6460 persist_node_cache : false ,
6561 } ) ?;
6662 let printed = workspace. format_file ( FormatFileParams {
6763 project_key,
68- path : std_in_file . clone ( ) ,
64+ path : biome_path . clone ( ) ,
6965 } ) ?;
7066
7167 let code = printed. into_code ( ) ;
@@ -80,7 +76,7 @@ pub(crate) fn run<'a>(
8076 } ) ;
8177 workspace. close_file ( CloseFileParams {
8278 project_key,
83- path : std_in_file . clone ( ) ,
79+ path : biome_path . clone ( ) ,
8480 } ) ?;
8581 } else {
8682 console. append ( markup ! {
@@ -96,7 +92,7 @@ pub(crate) fn run<'a>(
9692
9793 workspace. open_file ( OpenFileParams {
9894 project_key,
99- path : std_in_file . clone ( ) ,
95+ path : biome_path . clone ( ) ,
10096 content : FileContent :: from_client ( content) ,
10197 document_file_source : None ,
10298 persist_node_cache : false ,
@@ -147,7 +143,7 @@ pub(crate) fn run<'a>(
147143 let fix_file_result = workspace. fix_file ( FixFileParams {
148144 project_key,
149145 fix_file_mode : * fix_file_mode,
150- path : std_in_file . clone ( ) ,
146+ path : biome_path . clone ( ) ,
151147 should_format : mode. is_check ( ) && file_features. supports_format ( ) ,
152148 only : only. clone ( ) ,
153149 skip : skip. clone ( ) ,
@@ -167,7 +163,7 @@ pub(crate) fn run<'a>(
167163 workspace. change_file ( ChangeFileParams {
168164 project_key,
169165 content : output. clone ( ) ,
170- path : std_in_file . clone ( ) ,
166+ path : biome_path . clone ( ) ,
171167 version,
172168 } ) ?;
173169 new_content = Cow :: Owned ( output) ;
@@ -178,7 +174,7 @@ pub(crate) fn run<'a>(
178174 if file_features. supports_format ( ) && mode. is_check ( ) {
179175 let printed = workspace. format_file ( FormatFileParams {
180176 project_key,
181- path : std_in_file . clone ( ) ,
177+ path : biome_path . clone ( ) ,
182178 } ) ?;
183179 let code = printed. into_code ( ) ;
184180 let output = match biome_path. extension ( ) {
@@ -212,7 +208,7 @@ pub(crate) fn run<'a>(
212208 }
213209 workspace. close_file ( CloseFileParams {
214210 project_key,
215- path : std_in_file . clone ( ) ,
211+ path : biome_path . clone ( ) ,
216212 } ) ?;
217213 } else if let TraversalMode :: Search { pattern, .. } = mode. traversal_mode ( ) {
218214 // Make sure patterns are always cleaned up at the end of execution.
0 commit comments