Skip to content

Commit

Permalink
Merge pull request #64 from psibi/issue-42
Browse files Browse the repository at this point in the history
justl: Ability to set new working directory
  • Loading branch information
psibi authored Nov 16, 2024
2 parents 3b9b1a7 + 171974e commit 78e4626
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion justl.el
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ ARGS is a plist that affects how the process is run.
(justl-compilation-setup-buffer buf directory mode)
(with-current-buffer buf
(insert (format "Just target execution started at %s \n\n" (substring (current-time-string) 0 19)))
(let* ((process (apply
(let* ((default-directory directory)
(process (apply
#'start-file-process process-name buf command)))
(setq justl--compile-command command)
(setq-local justl-justfile (justl--justfile-from-arg (elt command 1)))
Expand All @@ -290,6 +291,12 @@ ARGS is a plist that affects how the process is run.
map)
"Keymap for justl compilation log buffers.")

(defun justl-set-new-working-dir (dir)
"Set DIR as the new working directory.
This is usually used with no-cd recipe attribute."
(interactive "DNew Working Directory:")
(setq-local default-directory dir))

(defun justl-recompile ()
"Execute the same just target again."
(interactive)
Expand Down Expand Up @@ -358,6 +365,7 @@ ARGS is a list of arguments."
(justl--log-command process-name cmd)
(justl--make-process cmd (list :buffer buffer-name
:process process-name
:directory default-directory
:mode mode))))

(defun justl--exec-without-justfile (process-name args)
Expand Down
5 changes: 5 additions & 0 deletions test/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ color:
#!/usr/bin/env bash
printf "\x1B[31mThis is red text\n"
# Some recipe
[no-cd]
recipe:
pwd

# private recipe
_private:
echo private
2 changes: 1 addition & 1 deletion test/justl-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

(ert-deftest justl--get-recipes-test ()
(should (equal
(list "default" "build-cmd" "plan" "push" "push2" "fail" "carriage-return" "color")
(list "default" "build-cmd" "plan" "push" "push2" "fail" "carriage-return" "color" "recipe")
(mapcar 'justl--recipe-name (justl--get-recipes "./justfile")))))

(ert-deftest justl--finds-recipe-test ()
Expand Down

0 comments on commit 78e4626

Please sign in to comment.