diff --git a/compiler/bsb/bsb_exception.ml b/compiler/bsb/bsb_exception.ml index 31db204b29..a4ccc93d85 100644 --- a/compiler/bsb/bsb_exception.ml +++ b/compiler/bsb/bsb_exception.ml @@ -23,19 +23,17 @@ * 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_json of string | Invalid_spec of string | Conflict_module of string * string * string | No_implementation of string - | Not_consistent of string 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 @@ -43,32 +41,22 @@ let print (fmt : Format.formatter) (x : error) = Format.fprintf fmt "@{Error:@} %s found in two directories: (%s, %s)\n\ File names must be unique per project" modname dir1 dir2 - | Not_consistent modname -> - Format.fprintf fmt - "@{Error:@} %s has implementation/interface in non-consistent \ - syntax(reason/ocaml)" - modname | No_implementation modname -> Format.fprintf fmt "@{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:@} package @{%s@} is not found %s\n\ + @{Error:@} package @{%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:@} package @{%s@} not found or built %s\n\ - - Did you install it?" name in_json + @{Error:@} package @{%s@} not found or built\n\ + - Did you install it?" name | Json_config (pos, s) -> Format.fprintf fmt "File %S, line %d:\n\ @@ -78,17 +66,12 @@ let print (fmt : Format.formatter) (x : error) = pos.pos_fname pos.pos_lnum s | Invalid_spec s -> Format.fprintf fmt "@{Error: Invalid bsconfig.json %s@}" s - | Invalid_json s -> - Format.fprintf fmt "File %S, line 1\n@{Error: Invalid json format@}" - s let conflict_module modname dir1 dir2 = Error (Conflict_module (modname, dir1, dir2)) let no_implementation modname = error (No_implementation modname) -let not_consistent modname = error (Not_consistent modname) - let errorf ~loc fmt = Format.ksprintf (fun s -> error (Json_config (loc, s))) fmt @@ -99,8 +82,6 @@ let config_error config fmt = let invalid_spec s = error (Invalid_spec s) -let invalid_json s = error (Invalid_json s) - let () = Printexc.register_printer (fun x -> match x with diff --git a/compiler/bsb/bsb_exception.mli b/compiler/bsb/bsb_exception.mli index 9f40866583..babe37c8c2 100644 --- a/compiler/bsb/bsb_exception.mli +++ b/compiler/bsb/bsb_exception.mli @@ -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 @@ -41,8 +41,4 @@ val config_error : Ext_json_types.t -> string -> 'a val invalid_spec : string -> 'a -val invalid_json : string -> 'a - val no_implementation : string -> 'a - -val not_consistent : string -> 'a diff --git a/compiler/bsb/bsb_pkg.ml b/compiler/bsb/bsb_pkg.ml index 87ac5cef4a..e542c7d271 100644 --- a/compiler/bsb/bsb_pkg.ml +++ b/compiler/bsb/bsb_pkg.ml @@ -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 @@ -97,35 +97,3 @@ let resolve_bs_package ~cwd (package : t) = "@{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 *) diff --git a/tests/build_tests/weird_deps/input.js b/tests/build_tests/weird_deps/input.js index 9199a61968..d76198e96e 100644 --- a/tests/build_tests/weird_deps/input.js +++ b/tests/build_tests/weird_deps/input.js @@ -17,7 +17,7 @@ if (out.stdout !== "") { normalizeNewlines(out.stderr), [ 'File "bsconfig.json", line 1', - "Error: package weird not found or built ", + "Error: package weird not found or built", "- Did you install it?", "", ].join("\n"), diff --git a/tests/build_tests/weird_devdeps/input.js b/tests/build_tests/weird_devdeps/input.js index 8bc6743ce5..77d621f892 100644 --- a/tests/build_tests/weird_devdeps/input.js +++ b/tests/build_tests/weird_devdeps/input.js @@ -17,7 +17,7 @@ if (out.stdout !== "") { out.stderr, [ 'File "bsconfig.json", line 1', - "Error: package weird not found or built ", + "Error: package weird not found or built", "- Did you install it?", "", ].join(os.EOL),