@@ -195,8 +195,8 @@ impl Args {
195195 }
196196}
197197
198- async fn create_fs ( name : & str , context : & str , watch : bool ) -> Result < Vc < Box < dyn FileSystem > > > {
199- let fs = DiskFileSystem :: new ( name. to_string ( ) , context . to_string ( ) ) ;
198+ async fn create_fs ( name : & str , root : & str , watch : bool ) -> Result < Vc < Box < dyn FileSystem > > > {
199+ let fs = DiskFileSystem :: new ( name. to_string ( ) , root . to_string ( ) ) ;
200200 if watch {
201201 fs. await ?. start_watching ( ) ?;
202202 } else {
@@ -206,30 +206,30 @@ async fn create_fs(name: &str, context: &str, watch: bool) -> Result<Vc<Box<dyn
206206}
207207
208208async fn add_glob_results (
209- context : Vc < Box < dyn AssetContext > > ,
209+ asset_context : Vc < Box < dyn AssetContext > > ,
210210 result : Vc < ReadGlobResult > ,
211211 list : & mut Vec < Vc < Box < dyn Module > > > ,
212212) -> Result < ( ) > {
213213 let result = result. await ?;
214214 for entry in result. results . values ( ) {
215215 if let DirectoryEntry :: File ( path) = entry {
216216 let source = Vc :: upcast ( FileSource :: new ( * path) ) ;
217- list. push ( context . process (
217+ list. push ( asset_context . process (
218218 source,
219219 Value :: new ( turbopack_core:: reference_type:: ReferenceType :: Undefined ) ,
220220 ) ) ;
221221 }
222222 }
223223 for result in result. inner . values ( ) {
224224 fn recurse < ' a > (
225- context : Vc < Box < dyn AssetContext > > ,
225+ asset_context : Vc < Box < dyn AssetContext > > ,
226226 result : Vc < ReadGlobResult > ,
227227 list : & ' a mut Vec < Vc < Box < dyn Module > > > ,
228228 ) -> Pin < Box < dyn Future < Output = Result < ( ) > > + Send + ' a > > {
229- Box :: pin ( add_glob_results ( context , result, list) )
229+ Box :: pin ( add_glob_results ( asset_context , result, list) )
230230 }
231231 // Boxing for async recursion
232- recurse ( context , * result, list) . await ?;
232+ recurse ( asset_context , * result, list) . await ?;
233233 }
234234 Ok ( ( ) )
235235}
@@ -240,16 +240,16 @@ async fn input_to_modules(
240240 input : Vec < String > ,
241241 exact : bool ,
242242 process_cwd : Option < String > ,
243- context : String ,
243+ context_directory : String ,
244244 module_options : TransientInstance < ModuleOptionsContext > ,
245245 resolve_options : TransientInstance < ResolveOptionsContext > ,
246246) -> Result < Vc < Modules > > {
247247 let root = fs. root ( ) ;
248248 let process_cwd = process_cwd
249249 . clone ( )
250- . map ( |p| p. trim_start_matches ( & context ) . to_owned ( ) ) ;
250+ . map ( |p| p. trim_start_matches ( & context_directory ) . to_owned ( ) ) ;
251251
252- let context : Vc < Box < dyn AssetContext > > = Vc :: upcast ( create_module_asset (
252+ let asset_context : Vc < Box < dyn AssetContext > > = Vc :: upcast ( create_module_asset (
253253 root,
254254 process_cwd,
255255 module_options,
@@ -260,42 +260,42 @@ async fn input_to_modules(
260260 for input in input {
261261 if exact {
262262 let source = Vc :: upcast ( FileSource :: new ( root. join ( input) ) ) ;
263- list. push ( context . process (
263+ list. push ( asset_context . process (
264264 source,
265265 Value :: new ( turbopack_core:: reference_type:: ReferenceType :: Undefined ) ,
266266 ) ) ;
267267 } else {
268268 let glob = Glob :: new ( input) ;
269- add_glob_results ( context , root. read_glob ( glob, false ) , & mut list) . await ?;
269+ add_glob_results ( asset_context , root. read_glob ( glob, false ) , & mut list) . await ?;
270270 } ;
271271 }
272272 Ok ( Vc :: cell ( list) )
273273}
274274
275275fn process_context ( dir : & Path , context_directory : Option < & String > ) -> Result < String > {
276- let mut context = PathBuf :: from ( context_directory. map_or ( "." , |s| s) ) ;
277- if !context . is_absolute ( ) {
278- context = dir. join ( context ) ;
276+ let mut context_directory = PathBuf :: from ( context_directory. map_or ( "." , |s| s) ) ;
277+ if !context_directory . is_absolute ( ) {
278+ context_directory = dir. join ( context_directory ) ;
279279 }
280280 // context = context.canonicalize().unwrap();
281- Ok ( context
281+ Ok ( context_directory
282282 . to_str ( )
283283 . ok_or_else ( || anyhow ! ( "context directory contains invalid characters" ) )
284284 . unwrap ( )
285285 . to_string ( ) )
286286}
287287
288- fn make_relative_path ( dir : & Path , context : & str , input : & str ) -> Result < String > {
288+ fn make_relative_path ( dir : & Path , context_directory : & str , input : & str ) -> Result < String > {
289289 let mut input = PathBuf :: from ( input) ;
290290 if !input. is_absolute ( ) {
291291 input = dir. join ( input) ;
292292 }
293293 // input = input.canonicalize()?;
294- let input = input. strip_prefix ( context ) . with_context ( || {
294+ let input = input. strip_prefix ( context_directory ) . with_context ( || {
295295 anyhow ! (
296296 "{} is not part of the context directory {}" ,
297297 input. display( ) ,
298- context
298+ context_directory
299299 )
300300 } ) ?;
301301 Ok ( input
@@ -304,10 +304,10 @@ fn make_relative_path(dir: &Path, context: &str, input: &str) -> Result<String>
304304 . replace ( '\\' , "/" ) )
305305}
306306
307- fn process_input ( dir : & Path , context : & str , input : & [ String ] ) -> Result < Vec < String > > {
307+ fn process_input ( dir : & Path , context_directory : & str , input : & [ String ] ) -> Result < Vec < String > > {
308308 input
309309 . iter ( )
310- . map ( |input| make_relative_path ( dir, context , input) )
310+ . map ( |input| make_relative_path ( dir, context_directory , input) )
311311 . collect ( )
312312}
313313
@@ -547,19 +547,19 @@ async fn main_operation(
547547 ref process_cwd,
548548 ..
549549 } = args. common ( ) ;
550- let context = process_context ( & dir, context_directory. as_ref ( ) ) . unwrap ( ) ;
551- let fs = create_fs ( "context directory" , & context , watch) . await ?;
550+ let context_directory = process_context ( & dir, context_directory. as_ref ( ) ) . unwrap ( ) ;
551+ let fs = create_fs ( "context directory" , & context_directory , watch) . await ?;
552552
553553 match * args {
554554 Args :: Print { common : _ } => {
555- let input = process_input ( & dir, & context , input) . unwrap ( ) ;
555+ let input = process_input ( & dir, & context_directory , input) . unwrap ( ) ;
556556 let mut result = BTreeSet :: new ( ) ;
557557 let modules = input_to_modules (
558558 fs,
559559 input,
560560 exact,
561561 process_cwd. clone ( ) ,
562- context ,
562+ context_directory ,
563563 module_options,
564564 resolve_options,
565565 )
@@ -577,15 +577,15 @@ async fn main_operation(
577577 return Ok ( Vc :: cell ( result. into_iter ( ) . collect :: < Vec < _ > > ( ) ) ) ;
578578 }
579579 Args :: Annotate { common : _ } => {
580- let input = process_input ( & dir, & context , input) . unwrap ( ) ;
580+ let input = process_input ( & dir, & context_directory , input) . unwrap ( ) ;
581581 let mut output_nft_assets = Vec :: new ( ) ;
582582 let mut emits = Vec :: new ( ) ;
583583 for module in input_to_modules (
584584 fs,
585585 input,
586586 exact,
587587 process_cwd. clone ( ) ,
588- context ,
588+ context_directory ,
589589 module_options,
590590 resolve_options,
591591 )
@@ -608,7 +608,7 @@ async fn main_operation(
608608 common : _,
609609 } => {
610610 let output = process_context ( & dir, Some ( output_directory) ) . unwrap ( ) ;
611- let input = process_input ( & dir, & context , input) . unwrap ( ) ;
611+ let input = process_input ( & dir, & context_directory , input) . unwrap ( ) ;
612612 let out_fs = create_fs ( "output directory" , & output, watch) . await ?;
613613 let input_dir = fs. root ( ) ;
614614 let output_dir = out_fs. root ( ) ;
@@ -618,7 +618,7 @@ async fn main_operation(
618618 input,
619619 exact,
620620 process_cwd. clone ( ) ,
621- context ,
621+ context_directory ,
622622 module_options,
623623 resolve_options,
624624 )
0 commit comments