Skip to content

Commit 5bb3db9

Browse files
committed
refactor: cleanup get_output_file and get_output_file_relative
1 parent 8da295e commit 5bb3db9

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

compiler/gentype/Paths.ml

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,14 @@ 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
55-
56-
let compute_absolute_output_file_path ~(config : Config.t) path =
57-
Filename.concat config.project_root (get_output_file_relative ~config path)
49+
let relativePath =
50+
remove_path_prefix ~prefix:config.project_root source_path
51+
in
52+
append_suffix ~config relativePath
5853

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
54+
let get_output_file ~(config : Config.t) source_path =
55+
let relative_output_path = get_output_file_relative ~config source_path in
56+
Filename.concat config.project_root relative_output_path
6957

7058
let get_module_name cmt =
7159
cmt |> handle_namespace |> Filename.basename |> ModuleName.from_string_unsafe

0 commit comments

Comments
 (0)