11open ! Core
22open Eio.Std
33
4- let version = " 2.3 .0"
4+ let version = " 2.4 .0"
55
66type counts = {
77 vue : int ref ;
@@ -33,7 +33,7 @@ type file_type =
3333type traversal = {
3434 table : String.Set .t String.Table .t ;
3535 counts : counts ;
36- wp : Eio.Workpool .t ;
36+ wp : Eio.Executor_pool .t ;
3737 slow_pug : bool ;
3838 template_script : Vue .template_script ;
3939 root : string ;
@@ -96,19 +96,23 @@ let process_job ({ path; _ } as job) =
9696
9797 Vue. collect_from_possible_scripts collector job.template_script
9898
99- let rec traverse ~fs ~stderr ({ slow_pug; template_script; counts; wp; _ } as traversal ) directory =
99+ let rec traverse ~fs ~stderr ({ slow_pug; template_script; counts; _ } as traversal ) directory =
100100 Eio.Path. with_open_dir Eio.Path. (fs / directory) Eio.Path. read_dir
101101 |> Fiber.List. iter (fun filename ->
102102 let path = Filename. concat directory filename in
103- match filename, Utils.Io. stat wp path with
103+ let eio_path = Eio.Path. (fs / path) in
104+ match filename, Eio.Path. kind ~follow: true eio_path with
104105 | "node_modules" , _ -> ()
105- | _ , { st_kind = S_DIR ; _ } -> traverse ~fs ~stderr traversal path
106- | _ , { st_kind = S_REG ; _ } -> (
106+ | _ , `Directory -> traverse ~fs ~stderr traversal path
107+ | _ , `Regular_file -> (
107108 match file_type_of_filename filename with
108109 | None -> ()
109110 | Some file_type ->
110- let job = { file_type; eio_path = Eio.Path. (fs / path); path; template_script; slow_pug } in
111- let collector = Eio.Workpool. submit_exn traversal.wp (fun () -> process_job job) in
111+ let job = { file_type; eio_path; path; template_script; slow_pug } in
112+ let collector =
113+ Eio.Executor_pool. submit_exn traversal.wp ~weight: Utils.Io. traversal_jobs_weight (fun () ->
114+ process_job job )
115+ in
112116 let count =
113117 match job.file_type with
114118 | JS -> counts.js
@@ -134,7 +138,7 @@ let main env options = function
134138 let languages = Vue. parse ~path ~slow_pug flow in
135139 Vue. debug_template ~stdout ~path languages template_script lang
136140 | Pug , ".pug" -> (
137- let source = Utils.Io. load_flow flow in
141+ let source = Eio.Flow. read_all flow in
138142 let slow_parse () =
139143 let collector = Utils.Collector. create ~path in
140144 Quickjs. extract_to_collector collector Pug source;
@@ -164,27 +168,22 @@ let main env options = function
164168 | _ -> Eio.Flow. copy_string (sprintf " Nothing to do for file [%s]\n " path) stdout )
165169| Run ->
166170 let overall_time = Utils.Timing. start () in
167- Switch. run @@ fun sw ->
168171 let outdir = options.outdir in
169172 if List. is_empty options.targets then failwith " Please specify at least one directory" ;
170173 let fs = Eio.Stdenv. fs env in
171174 let stdout = Eio.Stdenv. stdout env in
172- let sys_wp =
173- Eio.Workpool. create ~sw ~domain_count: Utils.Io. num_systhreads ~domain_concurrency: 1
174- (Eio.Stdenv. domain_mgr env)
175- in
176175 (* Check current directory *)
177176 let strings_dir_files =
178177 let git_dir, strings_dir =
179178 Fiber. pair
180- (fun () -> Utils.Io. directory_exists sys_wp " .git" )
181- (fun () -> Utils.Io. directory_exists sys_wp outdir)
179+ (fun () -> Eio.Path. is_directory Eio.Path. (fs / " .git" ) )
180+ (fun () -> Eio.Path. is_directory Eio.Path. (fs / outdir) )
182181 in
183182 if not (git_dir || strings_dir) then failwith " This program must be run from the root of your project" ;
184183 match strings_dir with
185184 | true -> Eio.Path. with_open_dir Eio.Path. (fs / outdir) Eio.Path. read_dir
186185 | false ->
187- Utils.Io. mkdir_p env sys_wp ~dir_name: outdir ~perms :0o751 ;
186+ Eio.Path. mkdirs ~exists_ok: true ~perm :0o751 Eio.Path. (fs / outdir) ;
188187 []
189188 in
190189
@@ -194,10 +193,7 @@ let main env options = function
194193 let table = String.Table. create () in
195194 let counts = { vue = ref 0 ; pug = ref 0 ; html = ref 0 ; js = ref 0 ; ts = ref 0 } in
196195 Switch. run @@ fun sw ->
197- let wp =
198- Eio.Workpool. create ~sw ~domain_count: Utils.Io. num_cores
199- ~domain_concurrency: Utils.Io. traversal_jobs_per_core (Eio.Stdenv. domain_mgr env)
200- in
196+ let wp = Eio.Executor_pool. create ~sw ~domain_count: Utils.Io. num_cores (Eio.Stdenv. domain_mgr env) in
201197 options.targets
202198 |> Fiber.List. iter (fun directory ->
203199 let root_slash, root_noslash =
@@ -242,9 +238,10 @@ let main env options = function
242238 | Some "english" -> ()
243239 | Some language -> (
244240 let path = Filename. concat outdir filename in
245- match Utils.Io. stat sys_wp path with
246- | { st_kind = S_REG ; _ } ->
247- let other = Eio.Path. with_open_in Eio.Path. (fs / path) (Parsing.Strings. parse ~path ) in
241+ let eio_path = Eio.Path. (fs / path) in
242+ match Eio.Path. kind ~follow: true eio_path with
243+ | `Regular_file ->
244+ let other = Eio.Path. with_open_in eio_path (Parsing.Strings. parse ~path ) in
248245 Generate. write_other ~fs ~stdout ~version ~outdir ~language english other
249246 | _ -> () )
250247 | None -> () )
0 commit comments