@@ -33,28 +33,30 @@ let remove_project_root_from_absolute_path ~(config : Config.t) source_path =
33
33
let n = String. length source_path - i in
34
34
(String. sub source_path i n [@ doesNotRaise])
35
35
36
- let getOutputFileRelative ~config source_path =
37
- if Filename. is_relative source_path then
38
- (source_path |> handleNamespace) ^ ModuleExtension. tsInputFileSuffix ~config
36
+ let appendSuffix ~config sourcePath =
37
+ (sourcePath |> handleNamespace) ^ ModuleExtension. tsInputFileSuffix ~config
38
+
39
+ let getOutputFileRelative ~config sourcePath =
40
+ if Filename. is_relative sourcePath then appendSuffix ~config sourcePath
39
41
else
40
42
let relative_path =
41
- remove_project_root_from_absolute_path ~config source_path
43
+ remove_project_root_from_absolute_path ~config sourcePath
42
44
in
43
- (relative_path |> handleNamespace)
44
- ^ ModuleExtension. tsInputFileSuffix ~config
45
+ appendSuffix ~config relative_path
46
+
47
+ let computeAbsoluteOutputFilePath ~(config : Config.t ) path =
48
+ Filename. concat config.projectRoot (getOutputFileRelative ~config path)
45
49
46
50
let getOutputFile ~(config : Config.t ) sourcePath =
47
51
if Filename. is_relative sourcePath then
48
52
(* assuming a relative path from the project root *)
49
- Filename. concat config.projectRoot
50
- (getOutputFileRelative ~config sourcePath)
53
+ computeAbsoluteOutputFilePath ~config sourcePath
51
54
else
52
- (* we want to place the output beside the source file *)
55
+ (* for absolute paths we want to place the output beside the source file *)
53
56
let relative_path =
54
57
remove_project_root_from_absolute_path ~config sourcePath
55
58
in
56
- Filename. concat config.projectRoot
57
- (getOutputFileRelative ~config relative_path)
59
+ computeAbsoluteOutputFilePath ~config relative_path
58
60
59
61
let getModuleName cmt =
60
62
cmt |> handleNamespace |> Filename. basename |> ModuleName. fromStringUnsafe
0 commit comments