@@ -106,6 +106,22 @@ let pkg_name_as_variable package =
106
106
|> fun s -> Ext_string. split s '-'
107
107
|> String. concat " _"
108
108
109
+ let rec find_dep_path ic package_name =
110
+ let line = input_line ic |> Ext_string. trim in
111
+ if Ext_string. starts_with line (" \" " ^ package_name ^ " @" ) then
112
+ input_line ic
113
+ |> Ext_string. trim
114
+ |> Ext_string. split_by (fun c -> c = '"' )
115
+ |> List. hd
116
+ else
117
+ find_dep_path ic package_name
118
+
119
+ let get_dep_path_from_file ~cwd package =
120
+ (* We should find the correct file if we move 3 steps up because we're in _esy/<sandbox>/store/b/<build> *)
121
+ let ic = open_in_bin Ext_path. (cwd // " .." // " .." // " .." // " installation.json" ) in
122
+ let package_name = Bsb_pkg_types. to_string package in
123
+ find_dep_path ic package_name
124
+
109
125
(* * TODO: collect all warnings and print later *)
110
126
let resolve_bs_package ~cwd (package : t ) =
111
127
if Lazy. force custom_resolution then
@@ -117,15 +133,17 @@ let resolve_bs_package ~cwd (package : t) =
117
133
| exception Not_found ->
118
134
begin
119
135
Bsb_log. error
120
- " @{<error>Custom resolution of package %s does not exist in var %s @} @."
136
+ " @{<error>Custom resolution@} of package @{<info>%s@} does not exist in var @{<info>%s@}, checking installation.json @."
121
137
(Bsb_pkg_types. to_string package)
122
138
custom_pkg_loc;
123
- Bsb_exception. package_not_found ~pkg: package ~json: None
139
+
140
+ try get_dep_path_from_file ~cwd package
141
+ with _ -> Bsb_exception. package_not_found ~pkg: package ~json: None
124
142
end
125
143
| path when not (Sys. file_exists path) ->
126
144
begin
127
145
Bsb_log. error
128
- " @{<error>Custom resolution of package %s does not exist on disk: %s=%s @} @."
146
+ " @{<error>Custom resolution@} of package @{<info>%s@} does not exist on disk: %s=%s @."
129
147
(Bsb_pkg_types. to_string package)
130
148
custom_pkg_loc
131
149
path;
@@ -134,7 +152,7 @@ let resolve_bs_package ~cwd (package : t) =
134
152
| path ->
135
153
begin
136
154
Bsb_log. info
137
- " @{<info>Custom Resolution of package %s in var %s found at %s@} @."
155
+ " @{<info>Custom Resolution@} of package %s in var %s found at %s@."
138
156
(Bsb_pkg_types. to_string package)
139
157
custom_pkg_loc
140
158
path;
0 commit comments