Skip to content

Instantly share code, notes, and snippets.

@ionrock
Last active December 31, 2015 13:29
Show Gist options
  • Save ionrock/7993530 to your computer and use it in GitHub Desktop.
Save ionrock/7993530 to your computer and use it in GitHub Desktop.
Adding some functions to read a project's procfile entries into prodigy. I use a tool called "xe" that does something similar to projectile in that it looks for a project root and appends venv/bin to your path before running commands. It also has some helpers to bootstrap a python virtualenv and run django manage commands. It makes these sorts o…
(defun my-procfile-name-from-line (line)
(car (split-string line ":")))
(defun my-procfile-names (procfile)
(with-temp-buffer
(insert-file-contents procfile)
(-map 'my-procfile-name-from-line (split-string (buffer-string) "\n" t))))
(defun my-procfile-cmd (procfile name)
(with-temp-buffer
(insert-file-contents procfile)
(search-forward-regexp (format "^%s: " name))
(split-string (buffer-substring (point) (line-end-position)))))
(defun my-prodigy-dicover-services ()
"Add services in the current projects Procfile(s)
A Procfile just starts with Procfile and may end with a suffix to
indicate its use case. For example `Procfile.dev` vs. `Procfile`."
(let ((procfiles (directory-files (projectile-project-root) t "Procfile*")))
(dolist (procfile procfiles)
(dolist (cmd (my-procfile-names procfile))
(prodigy-define-service
:name (format "%s-%s" procfile cmd)
:command "xe"
:args (my-procfile-cmd procfile cmd)
:cwd (projectile-project-root)
:path '((format "%svenv/bin" (projectile-project-root))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment