forked from emacs-taskrunner/emacs-taskrunner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskrunner-shell.el
52 lines (43 loc) · 1.8 KB
/
taskrunner-shell.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;;; taskrunner-shell.el --- Provide functions to retrieve shell script targets -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Yavor Konstantinov
;; TODO: Find a way to reliably run tasks in the shell where they must
;; run(powershell scripts in powershell, bash in bash...)
;;;; Commentary:
;; Support for:
;; - Bash
;; - Powershell
;; - Zsh
;;;; Code:
(require 'cl-lib)
;;;; Functions
(defun taskrunner--get-scripts (DIR FILETYPE-REGEXP PREFIX)
"Return a list of all scripts matching regexp FILETYPE-REGEXP in DIR.
All names are prefixed with the string provided by PREFIX."
(if (directory-name-p DIR)
(progn
(let ((shell-scripts (directory-files DIR nil FILETYPE-REGEXP)))
(cl-map 'list (lambda (elem)
(concat PREFIX " " elem))
shell-scripts)))))
(defun taskrunner-get-bash-scripts (DIR)
"Retrieve the rake tasks for the project in directory DIR.
This function returns a list of the form:
\(\"BASH TASK1\" \"BASH TASK2\"...)"
(taskrunner--get-scripts DIR "\\.sh$" "BASH"))
(defun taskrunner-get-powershell-scripts (DIR)
"Retrieve the rake tasks for the project in directory DIR.
This function returns a list of the form:
\(\"POWERSHELL TASK1\" \"POWERSHELL TASK2\"...)"
(taskrunner--get-scripts DIR "\\.ps1$" "POWERSHELL"))
(defun taskrunner-get-zsh-scripts (DIR)
"Retrieve the rake tasks for the project in directory DIR.
This function returns a list of the form:
\(\"ZSH TASK1\" \"ZSH TASK2\"...)"
(taskrunner--get-scripts DIR "\\.zsh$" "ZSH"))
(defun taskrunner-get-fish-scripts (DIR)
"Retrieve the rake tasks for the project in directory DIR.
This function returns a list of the form:
\(\"FISH TASK1\" \"FISH TASK2\"...)"
(taskrunner--get-scripts DIR "\\.fish$" "FISH"))
(provide 'taskrunner-shell)
;;; taskrunner-shell.el ends here