1
1
(* Copyright (C) 2017 Hongbo Zhang, Authors of ReScript
2
- *
2
+ *
3
3
* This program is free software: you can redistribute it and/or modify
4
4
* it under the terms of the GNU Lesser General Public License as published by
5
5
* the Free Software Foundation, either version 3 of the License, or
17
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
19
* GNU Lesser General Public License for more details.
20
- *
20
+ *
21
21
* You should have received a copy of the GNU Lesser General Public License
22
22
* along with this program; if not, write to the Free Software
23
23
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
@@ -43,18 +43,18 @@ let split_by_sep_per_os : string -> string list =
43
43
44
44
(* * example
45
45
{[
46
- "/bb/mbigc/mbig2899/bgit/bucklescript /jscomp/stdlib/external/pervasives.cmj"
47
- "/bb/mbigc/mbig2899/bgit/bucklescript /jscomp/stdlib/ocaml_array.ml"
46
+ "/bb/mbigc/mbig2899/bgit/rescript /jscomp/stdlib/external/pervasives.cmj"
47
+ "/bb/mbigc/mbig2899/bgit/rescript /jscomp/stdlib/ocaml_array.ml"
48
48
]}
49
49
50
50
The other way
51
51
{[
52
52
53
- "/bb/mbigc/mbig2899/bgit/bucklescript /jscomp/stdlib/ocaml_array.ml"
54
- "/bb/mbigc/mbig2899/bgit/bucklescript /jscomp/stdlib/external/pervasives.cmj"
53
+ "/bb/mbigc/mbig2899/bgit/rescript /jscomp/stdlib/ocaml_array.ml"
54
+ "/bb/mbigc/mbig2899/bgit/rescript /jscomp/stdlib/external/pervasives.cmj"
55
55
]}
56
56
{[
57
- "/bb/mbigc/mbig2899/bgit/bucklescript /jscomp/stdlib//ocaml_array.ml"
57
+ "/bb/mbigc/mbig2899/bgit/rescript /jscomp/stdlib//ocaml_array.ml"
58
58
]}
59
59
{[
60
60
/a/b
@@ -117,7 +117,7 @@ let ( // ) x y =
117
117
split_aux "//ghosg//ghsogh/";;
118
118
- : string * string list = ("/", ["ghosg"; "ghsogh"])
119
119
]}
120
- Note that
120
+ Note that
121
121
{[
122
122
Filename.dirname "/a/" = "/"
123
123
Filename.dirname "/a/b/" = Filename.dirname "/a/b" = "/a"
@@ -132,7 +132,7 @@ let ( // ) x y =
132
132
basename "" = "."
133
133
dirname "" = "."
134
134
dirname "" = "."
135
- ]}
135
+ ]}
136
136
*)
137
137
let split_aux p =
138
138
let rec go p acc =
@@ -149,11 +149,11 @@ let split_aux p =
149
149
150
150
go p []
151
151
152
- (* *
152
+ (* *
153
153
TODO: optimization
154
- if [from] and [to] resolve to the same path, a zero-length string is returned
154
+ if [from] and [to] resolve to the same path, a zero-length string is returned
155
155
156
- This function is useed in [es6-global] and
156
+ This function is useed in [es6-global] and
157
157
[amdjs-global] format and tailored for `rollup`
158
158
*)
159
159
let rel_normalized_absolute_path ~from to_ =
@@ -261,14 +261,17 @@ let concat dirname filename =
261
261
let check_suffix_case = Ext_string. ends_with
262
262
263
263
(* Input must be absolute directory *)
264
- let rec find_root_filename ~cwd filename =
265
- if Sys. file_exists (Filename. concat cwd filename) then cwd
264
+ let rec find_root_filename ~cwd filenames =
265
+ let file_exists = Ext_list. exists filenames (fun filename ->
266
+ Sys. file_exists (Filename. concat cwd filename))
267
+ in
268
+ if file_exists then cwd
266
269
else
267
270
let cwd' = Filename. dirname cwd in
268
271
if String. length cwd' < String. length cwd then
269
- find_root_filename ~cwd: cwd' filename
270
- else Ext_fmt. failwithf ~loc: __LOC__ " %s not found from %s" filename cwd
272
+ find_root_filename ~cwd: cwd' filenames
273
+ else Ext_fmt. failwithf ~loc: __LOC__ " %s not found from %s" ( List. hd filenames) cwd
271
274
272
- let find_package_json_dir cwd = find_root_filename ~cwd Literals. bsconfig_json
275
+ let find_config_dir cwd = find_root_filename ~cwd [ Literals. rescript_json; Literals. bsconfig_json]
273
276
274
- let package_dir = lazy (find_package_json_dir (Lazy. force cwd))
277
+ let package_dir = lazy (find_config_dir (Lazy. force cwd))
0 commit comments