1+ use deno_config:: glob:: FileCollector ;
12use deno_config:: glob:: FilePatterns ;
2- use deno_config:: glob:: { FileCollector , PathOrPatternSet } ;
3+ use deno_config:: glob:: PathOrPatternSet ;
34use deno_config:: workspace:: WorkspaceDirectory ;
45use deno_config:: workspace:: WorkspaceDiscoverOptions ;
56use deno_config:: workspace:: WorkspaceDiscoverStart ;
@@ -20,7 +21,8 @@ pub fn resolve_config(
2021 ignore_paths : Vec < String > ,
2122 allow_node_modules : bool ,
2223) -> Result < JsValue , JsValue > {
23- let result = inner_resolve_config ( root_path, ignore_paths, allow_node_modules) ;
24+ let result =
25+ inner_resolve_config ( root_path, ignore_paths, allow_node_modules) ;
2426 result
2527 . map_err ( |err| create_js_error ( & err) )
2628 . map ( |val| serde_wasm_bindgen:: to_value ( & val) . unwrap ( ) )
@@ -46,49 +48,50 @@ fn inner_resolve_config(
4648 maybe_vendor_override : None ,
4749 } ,
4850 ) ?;
49- if let Some ( deno_json) = workspace_dir. member_or_root_deno_json ( ) {
50- if let Some ( mut config) = deno_json. to_deploy_config ( ) ? {
51- if !ignore_paths. is_empty ( ) {
52- let exclude = PathOrPatternSet :: from_exclude_relative_path_or_patterns (
53- & config. files . base ,
54- & ignore_paths,
55- ) ?;
56- config
57- . files
58- . exclude
59- . append ( exclude. into_path_or_patterns ( ) . into_iter ( ) ) ;
60- }
6151
62- let files = collect_files ( & real_sys , root_path, config . files , allow_node_modules ) ;
52+ let mut pattern = FilePatterns :: new_with_base ( root_path. clone ( ) ) ;
6353
64- return Ok ( ConfigLookup {
65- path : Some ( deno_json. specifier . to_string ( ) ) ,
66- files,
67- } ) ;
68- } else {
69- let mut files_config = deno_json. to_exclude_files_config ( ) ?;
70- if !ignore_paths. is_empty ( ) {
71- let exclude = PathOrPatternSet :: from_exclude_relative_path_or_patterns (
72- & files_config. base ,
73- & ignore_paths,
74- ) ?;
75- files_config
76- . exclude
77- . append ( exclude. into_path_or_patterns ( ) . into_iter ( ) ) ;
78- }
79-
80- let files = collect_files ( & real_sys, root_path, files_config, allow_node_modules) ;
81- return Ok ( ConfigLookup {
82- path : Some ( deno_json. specifier . to_string ( ) ) ,
83- files,
84- } ) ;
85- }
54+ if !ignore_paths. is_empty ( ) {
55+ let exclude = PathOrPatternSet :: from_exclude_relative_path_or_patterns (
56+ & root_path,
57+ & ignore_paths,
58+ ) ?;
59+ pattern
60+ . exclude
61+ . append ( exclude. into_path_or_patterns ( ) . into_iter ( ) ) ;
8662 }
8763
88- Ok ( ConfigLookup {
89- path : None ,
90- files : collect_files ( & real_sys, root_path. clone ( ) , FilePatterns :: new_with_base ( root_path) , allow_node_modules) ,
91- } )
64+ if let Some ( config) = workspace_dir. to_deploy_config ( pattern) ? {
65+ let specifier = workspace_dir
66+ . member_deno_json ( )
67+ . filter ( |config| config. to_deploy_config ( ) . is_ok ( ) )
68+ . map ( |member| member. specifier . to_string ( ) )
69+ . or_else ( || {
70+ workspace_dir
71+ . member_or_root_deno_json ( )
72+ . filter ( |config| config. to_deploy_config ( ) . is_ok ( ) )
73+ . map ( |member| member. specifier . to_string ( ) )
74+ } )
75+ . expect (
76+ "workspace_dir.to_deploy_config should have resolved a specifier" ,
77+ ) ;
78+ let files =
79+ collect_files ( & real_sys, root_path, config. files , allow_node_modules) ;
80+ Ok ( ConfigLookup {
81+ path : Some ( specifier) ,
82+ files,
83+ } )
84+ } else {
85+ Ok ( ConfigLookup {
86+ path : None ,
87+ files : collect_files (
88+ & real_sys,
89+ root_path. clone ( ) ,
90+ FilePatterns :: new_with_base ( root_path) ,
91+ allow_node_modules,
92+ ) ,
93+ } )
94+ }
9295}
9396
9497fn collect_files (
@@ -97,17 +100,17 @@ fn collect_files(
97100 files : FilePatterns ,
98101 allow_node_modules : bool ,
99102) -> Vec < String > {
100- let mut collector = FileCollector :: new ( |entry| {
101- entry. path . starts_with ( & root_path)
102- } )
103- . ignore_git_folder ( )
104- . use_gitignore ( ) ;
103+ let mut collector =
104+ FileCollector :: new ( |entry| entry. path . starts_with ( & root_path) )
105+ . ignore_git_folder ( )
106+ . use_gitignore ( ) ;
105107
106108 if !allow_node_modules {
107109 collector = collector. ignore_node_modules ( ) ;
108110 }
109111
110- collector. collect_file_patterns ( real_sys, & files)
112+ collector
113+ . collect_file_patterns ( real_sys, & files)
111114 . into_iter ( )
112115 . map ( |path| path. to_string_lossy ( ) . to_string ( ) )
113116 . collect :: < Vec < String > > ( )
0 commit comments