Cache rake commands for run-command-recipe-rake
This commit is contained in:
parent
03caf4256f
commit
a96c2cd48b
@ -319,14 +319,33 @@
|
||||
:command-line "cargo build --release"
|
||||
:working-dir project-dir)))))
|
||||
|
||||
(defvar run-command-rake--cached-cmds nil)
|
||||
(defun run-command-rake--cache-cmds (project cmds)
|
||||
(setq run-command-rake--cached-cmds
|
||||
(plist-put run-command-rake--cached-cmds project cmds #'equal))
|
||||
(plist-get run-command-rake--cached-cmds project #'equal))
|
||||
(defun run-command-rake--get-cmds (project)
|
||||
(plist-get run-command-rake--cached-cmds project #'equal))
|
||||
(defun run-command-rake--reset-cache ()
|
||||
(interactive)
|
||||
(if-let ((rake-dir (or (locate-dominating-file default-directory "Rakefile")
|
||||
(locate-dominating-file default-directory "Rakefile.rb"))))
|
||||
(setq run-command-rake--cached-cmds
|
||||
(plist-put run-command-rake--cached-cmds rake-dir nil #'equal))
|
||||
(setq run-command-rake--cached-cmds nil)))
|
||||
|
||||
(defun run-command-recipe-rake ()
|
||||
(when-let* ((rake-dir (or (locate-dominating-file default-directory "Rakefile")
|
||||
(locate-dominating-file default-directory "Rakefile.rb")))
|
||||
(cmds (->> (shell-command-to-string "rake -T")
|
||||
(s-split "\n")
|
||||
(-map (lambda (s) (s-split-up-to " " s 2)))
|
||||
(-map (lambda (l) (s-join " " (-take 2 l))))
|
||||
(-filter (-not 'string-empty-p)))))
|
||||
(cmds (if-let ((cmds (run-command-rake--get-cmds rake-dir)))
|
||||
cmds
|
||||
(run-command-rake--cache-cmds
|
||||
rake-dir
|
||||
(->> (shell-command-to-string "rake -T")
|
||||
(s-split "\n")
|
||||
(-map (lambda (s) (s-split-up-to " " s 2)))
|
||||
(-map (lambda (l) (s-join " " (-take 2 l))))
|
||||
(-filter (-not 'string-empty-p)))))))
|
||||
(-map (lambda (cmd)
|
||||
(list :command-name (cadr (s-split " " cmd))
|
||||
:command-line cmd
|
||||
@ -376,6 +395,16 @@
|
||||
:command-line (format "rspec %s" (buffer-file-name))
|
||||
:working-dir root-dir)))))
|
||||
|
||||
(defun run-command-recipe-hummingbird ()
|
||||
(let* ((project (projectile-project-root))
|
||||
(project-name (f-filename project)))
|
||||
(append (when (equal project-name "hummingbird-rails")
|
||||
(list
|
||||
(list :command-name "workbench start"
|
||||
:command-line "./workbench/bin/start"
|
||||
:working-dir project
|
||||
:runner 'run-command-runner-vterm))))))
|
||||
|
||||
:general
|
||||
(leader-map "\"" #'run-command)
|
||||
:custom
|
||||
@ -399,6 +428,7 @@
|
||||
run-command-recipe-cargo
|
||||
run-command-recipe-rake
|
||||
run-command-recipe-scripts
|
||||
run-command-recipe-rspec)))
|
||||
run-command-recipe-rspec
|
||||
run-command-recipe-hummingbird)))
|
||||
|
||||
(provide 'init-run-command)
|
||||
|
Loading…
Reference in New Issue
Block a user