Skip to content

Commit 0e383fb

Browse files
committed
Make filename pure
1 parent 828d2e1 commit 0e383fb

14 files changed

+354
-269
lines changed

jscomp/bsb/bsb_parse_sources.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ let rec
390390
parsing_source_dir_map
391391
{cxt with
392392
cwd = Ext_path.concat cxt.cwd
393-
(Ext_filename.simple_convert_node_path_to_os_path x);
393+
(Ext_path.simple_convert_node_path_to_os_path x);
394394
traverse = true
395395
} String_map.empty) origin
396396
else origin
@@ -423,7 +423,7 @@ and parsing_single_source ({not_dev; dir_index ; cwd} as cxt ) (x : Ext_json_typ
423423
else
424424
parsing_source_dir_map
425425
{cxt with
426-
cwd = Ext_path.concat cwd (Ext_filename.simple_convert_node_path_to_os_path dir)}
426+
cwd = Ext_path.concat cwd (Ext_path.simple_convert_node_path_to_os_path dir)}
427427
String_map.empty
428428
| Obj {map} ->
429429
let current_dir_index =
@@ -438,7 +438,7 @@ and parsing_single_source ({not_dev; dir_index ; cwd} as cxt ) (x : Ext_json_typ
438438
let dir =
439439
match String_map.find_opt map Bsb_build_schemas.dir with
440440
| Some (Str{str}) ->
441-
Ext_filename.simple_convert_node_path_to_os_path str
441+
Ext_path.simple_convert_node_path_to_os_path str
442442
| Some x -> Bsb_exception.config_error x "dir expected to be a string"
443443
| None ->
444444
Bsb_exception.config_error x
@@ -501,13 +501,13 @@ and walk_single_source cxt (x : Ext_json_types.t) =
501501
match x with
502502
| Str {str = dir}
503503
->
504-
let dir = Ext_filename.simple_convert_node_path_to_os_path dir in
504+
let dir = Ext_path.simple_convert_node_path_to_os_path dir in
505505
walk_source_dir_map
506506
{cxt with cwd = Ext_path.concat cxt.cwd dir } None
507507
| Obj {map} ->
508508
begin match String_map.find_opt map Bsb_build_schemas.dir with
509509
| Some (Str{str}) ->
510-
let dir = Ext_filename.simple_convert_node_path_to_os_path str in
510+
let dir = Ext_path.simple_convert_node_path_to_os_path str in
511511
walk_source_dir_map
512512
{cxt with cwd = Ext_path.concat cxt.cwd dir} (String_map.find_opt map Bsb_build_schemas.subdirs)
513513
| _ -> ()
@@ -535,7 +535,7 @@ and walk_source_dir_map (cxt : walk_cxt) sub_dirs_field =
535535
{cxt with
536536
cwd =
537537
Ext_path.concat cxt.cwd
538-
(Ext_filename.simple_convert_node_path_to_os_path f);
538+
(Ext_path.simple_convert_node_path_to_os_path f);
539539
traverse = true
540540
} None
541541
end

jscomp/ext/ext_filename.ml

-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626

2727

2828

29-
let simple_convert_node_path_to_os_path =
30-
if Sys.unix then fun x -> x
31-
else if Sys.win32 || Sys.cygwin then
32-
Ext_string.replace_slash_backward
33-
else failwith ("Unknown OS : " ^ Sys.os_type)
3429

3530
(* reference ninja.cc IsKnownShellSafeCharacter *)
3631
let maybe_quote ( s : string) =

jscomp/ext/ext_filename.mli

-10
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@
3939
TODO : this short name will have to change upon renaming the file.
4040
*)
4141

42-
(** Js_output is node style, which means
43-
separator is only '/'
44-
45-
if the path contains 'node_modules',
46-
[node_relative_path] will discard its prefix and
47-
just treat it as a library instead
48-
*)
49-
50-
51-
val simple_convert_node_path_to_os_path : string -> string
5242

5343
val maybe_quote:
5444
string ->

jscomp/ext/ext_path.ml

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ type t =
2727
| Dir of string
2828

2929

30+
let simple_convert_node_path_to_os_path =
31+
if Sys.unix then fun x -> x
32+
else if Sys.win32 || Sys.cygwin then
33+
Ext_string.replace_slash_backward
34+
else failwith ("Unknown OS : " ^ Sys.os_type)
3035

3136

3237
let cwd = lazy (Sys.getcwd())

jscomp/ext/ext_path.mli

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
type t
2626

2727

28+
(** Js_output is node style, which means
29+
separator is only '/'
30+
31+
if the path contains 'node_modules',
32+
[node_relative_path] will discard its prefix and
33+
just treat it as a library instead
34+
*)
35+
val simple_convert_node_path_to_os_path : string -> string
2836

2937

3038

0 commit comments

Comments
 (0)