Skip to content

Commit 9759b80

Browse files
committedOct 20, 2024
refactor: cleanup get_output_file and get_output_file_relative
1 parent 4f4a1c3 commit 9759b80

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed
 

‎compiler/gentype/Paths.ml

+7-16
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,17 @@ let append_suffix ~config source_path =
4646
^ ModuleExtension.ts_input_file_suffix ~config
4747

4848
let get_output_file_relative ~(config : Config.t) source_path =
49-
if Filename.is_relative source_path then append_suffix ~config source_path
50-
else
51-
let relative_path =
52-
remove_path_prefix ~prefix:config.project_root source_path
53-
in
54-
append_suffix ~config relative_path
49+
let relativePath =
50+
remove_path_prefix ~prefix:config.project_root source_path
51+
in
52+
append_suffix ~config relativePath
5553

5654
let compute_absolute_output_file_path ~(config : Config.t) path =
5755
Filename.concat config.project_root (get_output_file_relative ~config path)
5856

59-
let get_output_file ~(config : Config.t) sourcePath =
60-
if Filename.is_relative sourcePath then
61-
(* assuming a relative path from the project root *)
62-
compute_absolute_output_file_path ~config sourcePath
63-
else
64-
(* for absolute paths we want to place the output beside the source file *)
65-
let relative_path =
66-
remove_path_prefix ~prefix:config.project_root sourcePath
67-
in
68-
compute_absolute_output_file_path ~config relative_path
57+
let get_output_file ~(config : Config.t) source_path =
58+
let relative_output_path = get_output_file_relative ~config source_path in
59+
Filename.concat config.project_root relative_output_path
6960

7061
let get_module_name cmt =
7162
cmt |> handle_namespace |> Filename.basename |> ModuleName.from_string_unsafe

0 commit comments

Comments
 (0)