Skip to content

Commit

Permalink
Bsb_exception.Package_not_found: removed unused param
Browse files Browse the repository at this point in the history
  • Loading branch information
cknitt committed Oct 26, 2024
1 parent ba98683 commit 66c106d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 46 deletions.
19 changes: 7 additions & 12 deletions compiler/bsb/bsb_exception.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type error =
| Package_not_found of Bsb_pkg_types.t * string option (* json file *)
| Package_not_found of Bsb_pkg_types.t
| Json_config of Ext_position.t * string
| Invalid_spec of string
| Conflict_module of string * string * string
Expand All @@ -33,7 +33,7 @@ exception Error of error

let error err = raise (Error err)

let package_not_found ~pkg ~json = error (Package_not_found (pkg, json))
let package_not_found ~pkg = error (Package_not_found pkg)

let print (fmt : Format.formatter) (x : error) =
match x with
Expand All @@ -44,24 +44,19 @@ let print (fmt : Format.formatter) (x : error) =
| No_implementation modname ->
Format.fprintf fmt "@{<error>Error:@} %s does not have implementation file"
modname
| Package_not_found (name, json_opt) ->
let in_json =
match json_opt with
| None -> Ext_string.empty
| Some x -> " in " ^ x
in
| Package_not_found name ->
let name = Bsb_pkg_types.to_string name in
if Ext_string.equal name !Bs_version.package_name then
Format.fprintf fmt
"File \"bsconfig.json\", line 1\n\
@{<error>Error:@} package @{<error>%s@} is not found %s\n\
@{<error>Error:@} package @{<error>%s@} is not found\n\
It's the basic, required package. If you have it installed globally,\n\
Please run `npm link rescript` to make it available" name in_json
Please run `npm link rescript` to make it available" name
else
Format.fprintf fmt
"File \"bsconfig.json\", line 1\n\
@{<error>Error:@} package @{<error>%s@} not found or built %s\n\
- Did you install it?" name in_json
@{<error>Error:@} package @{<error>%s@} not found or built\n\
- Did you install it?" name
| Json_config (pos, s) ->
Format.fprintf fmt
"File %S, line %d:\n\
Expand Down
2 changes: 1 addition & 1 deletion compiler/bsb/bsb_exception.mli
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ exception Error of error

val print : Format.formatter -> error -> unit

val package_not_found : pkg:Bsb_pkg_types.t -> json:string option -> 'a
val package_not_found : pkg:Bsb_pkg_types.t -> 'a

val conflict_module : string -> string -> string -> exn

Expand Down
34 changes: 1 addition & 33 deletions compiler/bsb/bsb_pkg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ let resolve_bs_package_aux ~cwd (pkg : t) =
check_dir (dir // Bsb_pkg_types.to_string pkg))
with
| Some resolved_dir -> resolved_dir
| None -> Bsb_exception.package_not_found ~pkg ~json:None
| None -> Bsb_exception.package_not_found ~pkg
in
aux cwd

Expand Down Expand Up @@ -97,35 +97,3 @@ let resolve_bs_package ~cwd (package : t) =
"@{<warning>Duplicated package:@} %a %s (chosen) vs %s in %s @."
Bsb_pkg_types.print package x result cwd;
x

(** The package does not need to be a bspackage
example:
{[
resolve_npm_package_file ~cwd "reason/refmt";;
resolve_npm_package_file ~cwd "reason/refmt/xx/yy"
]}
It also returns the path name
Note the input [sub_path] is already converted to physical meaning path according to OS
*)
(* let resolve_npm_package_file ~cwd sub_path = *)
(* let rec aux cwd = *)
(* let abs_marker = cwd // Literals.node_modules // sub_path in *)
(* if Sys.file_exists abs_marker then Some abs_marker *)
(* else *)
(* let cwd' = Filename.dirname cwd in *)
(* if String.length cwd' < String.length cwd then *)
(* aux cwd' *)
(* else *)
(* try *)
(* let abs_marker = *)
(* Sys.getenv "npm_config_prefix" *)
(* // "lib" // Literals.node_modules // sub_path in *)
(* if Sys.file_exists abs_marker *)
(* then Some abs_marker *)
(* else None *)
(* (\* Bs_exception.error (Bs_package_not_found name) *\) *)
(* with *)
(* Not_found -> None *)
(* (\* Bs_exception.error (Bs_package_not_found name) *\) *)
(* in *)
(* aux cwd *)

0 comments on commit 66c106d

Please sign in to comment.