Skip to content

Commit 4c12227

Browse files
committed
refactor: cleanup getOutputFile and getOutputFileRelative
1 parent 384c14e commit 4c12227

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

jscomp/gentype/Paths.ml

+6-20
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,13 @@ let removePathPrefix ~prefix path =
4343
let appendSuffix ~config sourcePath =
4444
(sourcePath |> handleNamespace) ^ ModuleExtension.tsInputFileSuffix ~config
4545

46-
let getOutputFileRelative ~config sourcePath =
47-
if Filename.is_relative sourcePath then appendSuffix ~config sourcePath
48-
else
49-
let relative_path =
50-
removePathPrefix ~prefix:config.projectRoot sourcePath
51-
in
52-
appendSuffix ~config relative_path
53-
54-
let computeAbsoluteOutputFilePath ~(config : Config.t) path =
55-
Filename.concat config.projectRoot (getOutputFileRelative ~config path)
46+
let getOutputFileRelative ~(config : Config.t) path =
47+
let relativePath = removePathPrefix ~prefix:config.projectRoot path in
48+
appendSuffix ~config relativePath
5649

57-
let getOutputFile ~(config : Config.t) sourcePath =
58-
if Filename.is_relative sourcePath then
59-
(* assuming a relative path from the project root *)
60-
computeAbsoluteOutputFilePath ~config sourcePath
61-
else
62-
(* for absolute paths we want to place the output beside the source file *)
63-
let relative_path =
64-
removePathPrefix ~prefix:config.projectRoot sourcePath
65-
in
66-
computeAbsoluteOutputFilePath ~config relative_path
50+
let getOutputFile ~(config : Config.t) absoluteSourcePath =
51+
let relativeOutputPath = getOutputFileRelative ~config absoluteSourcePath in
52+
Filename.concat config.projectRoot relativeOutputPath
6753

6854
let getModuleName cmt =
6955
cmt |> handleNamespace |> Filename.basename |> ModuleName.fromStringUnsafe

0 commit comments

Comments
 (0)