@@ -11,25 +11,24 @@ let makePathsForModule ~projectFilesAndPaths ~dependenciesFilesAndPaths =
11
11
Hashtbl. replace pathsForModule modName paths);
12
12
pathsForModule
13
13
14
- let newBsPackage rootPath =
15
- let path = Filename. concat rootPath " bsconfig.json" in
16
- match Files. readFile path with
17
- | None -> Error (" Unable to read " ^ path)
14
+ let newBsPackage ~rootPath =
15
+ let bsconfig = Filename. concat rootPath " bsconfig.json" in
16
+ match Files. readFile bsconfig with
17
+ | None ->
18
+ Log. log (" Unable to read " ^ bsconfig);
19
+ None
18
20
| Some raw -> (
19
21
let config = Json. parse raw in
20
22
Log. log {| 📣 📣 NEW BSB PACKAGE 📣 📣| };
21
23
Log. log (" - location: " ^ rootPath);
22
24
let libBs = BuildSystem. getLibBs rootPath in
23
25
match FindFiles. findDependencyFiles rootPath config with
24
- | Error e -> Error e
25
- | Ok (dependencyDirectories , dependenciesFilesAndPaths ) -> (
26
+ | None -> None
27
+ | Some (dependencyDirectories , dependenciesFilesAndPaths ) -> (
26
28
match libBs with
27
- | None ->
28
- Error
29
- " Please run the build first so that the editor can analyze the \
30
- project's artifacts."
29
+ | None -> None
31
30
| Some libBs ->
32
- Ok
31
+ Some
33
32
(let namespace = FindFiles. getNamespace config in
34
33
let sourceDirectories =
35
34
FindFiles. getSourceDirectories ~include Dev:true ~base Dir:rootPath
@@ -111,17 +110,20 @@ let findRoot ~uri packagesByRoot =
111
110
let getPackage ~uri =
112
111
let open SharedTypes in
113
112
if Hashtbl. mem state.rootForUri uri then
114
- Ok (Hashtbl. find state.packagesByRoot (Hashtbl. find state.rootForUri uri))
113
+ Some (Hashtbl. find state.packagesByRoot (Hashtbl. find state.rootForUri uri))
115
114
else
116
115
match findRoot ~uri state.packagesByRoot with
117
- | None -> Error " No root directory found"
116
+ | None ->
117
+ Log. log " No root directory found" ;
118
+ None
118
119
| Some (`Root rootPath ) ->
119
120
Hashtbl. replace state.rootForUri uri rootPath;
120
- Ok (Hashtbl. find state.packagesByRoot (Hashtbl. find state.rootForUri uri))
121
+ Some
122
+ (Hashtbl. find state.packagesByRoot (Hashtbl. find state.rootForUri uri))
121
123
| Some (`Bs rootPath ) -> (
122
- match newBsPackage rootPath with
123
- | Error e -> Error e
124
- | Ok package ->
124
+ match newBsPackage ~ root Path with
125
+ | None -> None
126
+ | Some package ->
125
127
Hashtbl. replace state.rootForUri uri package.rootPath;
126
128
Hashtbl. replace state.packagesByRoot package.rootPath package;
127
- Ok package)
129
+ Some package)
0 commit comments