Function: projectile-run-task
projectile-run-task is an autoloaded, interactive and byte-compiled
function defined in projectile.el.
Signature
(projectile-run-task ARG)
Documentation
Run one of the current project's named tasks.
The task is picked with completion among the tasks of the project's
type, those in projectile-tasks (which win for same-named tasks) and
the ones discovered in the project's own tooling - npm scripts, Makefile
targets and the like, named after the tool that defines them (see
projectile-project-tasks and projectile-task-providers). With a
prefix ARG the task's command can be edited before it's run, e.g. to
pass it ad-hoc arguments.
The command runs through the same machinery as
projectile-compile-project - in projectile-compilation-dir, with
%p expanded to the project name - but its output goes to a per-task
compilation buffer named after the task.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
;;;###autoload
(defun projectile-run-task (arg)
"Run one of the current project's named tasks.
The task is picked with completion among the tasks of the project's
type, those in `projectile-tasks' (which win for same-named tasks) and
the ones discovered in the project's own tooling - npm scripts, Makefile
targets and the like, named after the tool that defines them (see
`projectile-project-tasks' and `projectile-task-providers'). With a
prefix ARG the task's command can be edited before it's run, e.g. to
pass it ad-hoc arguments.
The command runs through the same machinery as
`projectile-compile-project' - in `projectile-compilation-dir', with
`%p' expanded to the project name - but its output goes to a per-task
compilation buffer named after the task."
(interactive "P")
;; Establish we're in a project before prompting, so the task menu
;; doesn't pop up (with globally-defined tasks) outside one.
(let ((tasks (projectile-project-tasks nil (projectile-acquire-root))))
(unless tasks
(user-error "No tasks defined for the current project"))
(let* ((task-name (projectile-completing-read "Run task: " (mapcar #'car tasks)))
(task (assoc task-name tasks)))
(unless task
(user-error "No task named `%s' in the current project" task-name))
(projectile--run-task task-name (cdr task) arg))))