Skip to content

Commit

Permalink
refactor: move refmt/rescript_syntax hints to rules (#10795)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored Aug 4, 2024
1 parent 42ed194 commit 6de363f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 2 additions & 11 deletions src/dune_engine/action.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,10 @@ module Prog = struct

let create ?hint ~context ~program ~loc () = { hint; context; program; loc }

let user_message { context; program; hint; loc } =
let hint =
match program with
| "refmt" -> Some (Option.value ~default:"opam install reason" hint)
| "rescript_syntax" ->
Some (Option.value ~default:"opam install rescript-syntax" hint)
| _ -> hint
in
Utils.program_not_found_message ?hint ~loc ~context program
let raise { context; program; hint; loc } =
raise (User_error.E (Utils.program_not_found_message ?hint ~loc ~context program))
;;

let raise t = raise (User_error.E (user_message t))

let to_dyn { context; program; hint; loc = _ } =
let open Dyn in
record
Expand Down
8 changes: 7 additions & 1 deletion src/dune_rules/action_unexpanded.ml
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,13 @@ end = struct
then Artifacts.Original_path
else Install_dir
and* artifacts = Expander.artifacts env.expander in
Artifacts.binary ~loc:(Some loc) ~where artifacts s)
let hint =
match s with
| "refmt" -> Some "opam install reason"
| "rescript_syntax" -> Some "opam install rescript-syntax"
| _ -> None
in
Artifacts.binary ?hint ~loc:(Some loc) ~where artifacts s)
in
let prog = Result.map prog ~f:(Expander.map_exe env.expander) in
let args = Value.L.to_strings ~dir args in
Expand Down

0 comments on commit 6de363f

Please sign in to comment.