@@ -34,29 +34,31 @@ let remove_project_root_from_absolute_path ~(config : Config.t) source_path =
34
34
let n = String. length source_path - i in
35
35
(String. sub source_path i n [@ doesNotRaise])
36
36
37
- let get_output_file_relative ~config source_path =
38
- if Filename. is_relative source_path then
39
- (source_path |> handle_namespace)
40
- ^ ModuleExtension. ts_input_file_suffix ~config
37
+ let append_suffix ~config source_path =
38
+ (source_path |> handle_namespace)
39
+ ^ ModuleExtension. ts_input_file_suffix ~config
40
+
41
+ let get_output_file_relative ~(config : Config.t ) source_path =
42
+ if Filename. is_relative source_path then append_suffix ~config source_path
41
43
else
42
44
let relative_path =
43
45
remove_project_root_from_absolute_path ~config source_path
44
46
in
45
- (relative_path |> handle_namespace)
46
- ^ ModuleExtension. ts_input_file_suffix ~config
47
+ append_suffix ~config relative_path
48
+
49
+ let compute_absolute_output_file_path ~(config : Config.t ) path =
50
+ Filename. concat config.project_root (get_output_file_relative ~config path)
47
51
48
52
let get_output_file ~(config : Config.t ) sourcePath =
49
53
if Filename. is_relative sourcePath then
50
54
(* assuming a relative path from the project root *)
51
- Filename. concat config.project_root
52
- (get_output_file_relative ~config sourcePath)
55
+ compute_absolute_output_file_path ~config sourcePath
53
56
else
54
- (* we want to place the output beside the source file *)
57
+ (* for absolute paths we want to place the output beside the source file *)
55
58
let relative_path =
56
59
remove_project_root_from_absolute_path ~config sourcePath
57
60
in
58
- Filename. concat config.project_root
59
- (get_output_file_relative ~config relative_path)
61
+ compute_absolute_output_file_path ~config relative_path
60
62
61
63
let get_module_name cmt =
62
64
cmt |> handle_namespace |> Filename. basename |> ModuleName. from_string_unsafe
0 commit comments