Skip to content

Commit

Permalink
Merge pull request #62 from psibi/issue-41
Browse files Browse the repository at this point in the history
Fix issue 41
  • Loading branch information
psibi authored Nov 15, 2024
2 parents 649490d + c5c42de commit befc733
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Changelog.org
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
buffer.
- Bugfix: Use the buffer's last command for recompile, not the last
one across all buffers.
- Support optional argument prompting in
~justl-exec-recipe-in-dir~. Fixes [[https://github.com/psibi/justl.el/issues/41][issue 41]].

* 0.14

Expand Down
6 changes: 5 additions & 1 deletion justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ They are returned as objects, as per the JSON output of \"just --dump\"."
(recipe-name (completing-read "Recipes: "
(mapcar 'justl--recipe-name recipes)
nil t nil nil))
(recipe (cdr (assoc recipe-name recipes))))
(recipe (justl--find-recipes recipes recipe-name)))
(justl--exec-without-justfile
justl-executable
(cons recipe-name
Expand Down Expand Up @@ -646,6 +646,10 @@ is not executed."
('nil nil)
(_ default)))))

(defun justl--find-recipes (recipes name)
"Return recipe from RECIPES matching NAME."
(seq-first (seq-filter (lambda (recipe) (string= (recipe-name recipe) name)) recipes)))

(defun justl-exec-recipe ()
"Execute just recipe."
(interactive)
Expand Down
5 changes: 5 additions & 0 deletions test/justl-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
(list "default" "build-cmd" "plan" "push" "push2" "fail" "carriage-return" "color")
(mapcar 'justl--recipe-name (justl--get-recipes "./justfile")))))

(ert-deftest justl--finds-recipe-test ()
(let* ((recipes (justl--get-recipes "./justfile"))
(recipe (justl--find-recipes recipes "default")))
(should (string= (recipe-doc recipe) "List all recipes"))))

(ert-deftest justl--get-description-test ()
(let* ((recipes (justl--get-recipes "./justfile"))
(recipe (seq-find (lambda (r) (string= "default" (justl--recipe-name r))) recipes)))
Expand Down

0 comments on commit befc733

Please sign in to comment.