-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
117 lines (105 loc) · 3.87 KB
/
Taskfile.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
version: "3"
# dotenv does not work in included taskfiles. Include the init env files here, so they are available for the init tasks.
dotenv:
- 'init/env-{{OS}}-{{ARCH}}.txt'
# Global environmental variables
env:
TASKFILE_BIN_DIR: '{{.TASKFILE_BIN_DIR}}'
# Global variables
vars:
# FS_PATH_SEP is the OS-specific separator for filesystem paths.
FS_PATH_SEP: '{{ if eq OS "windows" }}\{{ else }}/{{ end }}'
# ENV_PATH_SEP is the OS-specific separator for the PATH environmental variable.
ENV_PATH_SEP: '{{ if eq OS "windows" }};{{ else }}:{{ end }}'
# HAS_SYSTEM_PERMISSION determines if the user has system or admin privileges. Returns "true" if the task is run as
# a root on \*nix or a user that is a member of the administrator's group on Windows.
# Use "whoami" instead of "net session" to determine permissions.
# The full path is used to prevent conflicts with "/usr/bin/whoami" when using bash as the login shell for ssh.
HAS_SYSTEM_PERMISSION:
sh: |
{{- if eq OS "windows" -}}
whoami="$(C:/Windows/System32/whoami.exe /groups)"
if [[ "$whoami" == *"Mandatory Label\\High Mandatory Level"* ]]; then
echo 'true'
else
echo ''
fi
{{- else -}}
echo '{{ if eq .USER "root" }}true{{ end }}'
{{- end -}}
# BIN_DIR is the directory to hold the binaries. If run as root/administrator, the system directory is used.
# Otherwise, the user's bin directory is used.
# Task treats environmental variables as case-sensitive while Windows does not.
# Pass the path to osClean to make sure backslashes are handled on Windows.
# The test operator adds a blank space at the end to account for Window's backslash which will escape the quote.
BIN_DIR:
sh: |
if [ "${TASKFILE_BIN_DIR} " != " " ]; then
# ENV_VAR="some var" task task-name
echo "${TASKFILE_BIN_DIR}"
elif [ "{{.TASKFILE_BIN_DIR}} " != " " ]; then
# task task-name ENV_VAR="some var"
echo "{{.TASKFILE_BIN_DIR}} "
else
# TASKFILE_BIN_DIR not defined
{{ if eq OS "windows" -}}
{{- if .HAS_SYSTEM_PERMISSION -}}
{{- if .ProgramData -}}
echo '{{ print .ProgramData "/taskfiles/bin" | osClean -}}'
{{- else if .PROGRAMDATA -}}
echo '{{ print .PROGRAMDATA "/taskfiles/bin" | osClean -}}'
{{- else -}}
echo ''
{{- end -}}
{{- else -}}
echo '{{ if .USERPROFILE }}{{ print .USERPROFILE "/bin" | osClean -}}{{ end }}'
{{- end -}}
{{- else -}}
echo "{{ if .HAS_SYSTEM_PERMISSION }}/usr/local/bin{{ else }}{{.HOME}}/bin{{ end }}"
{{- end }}
fi
# Append BIN_DIR to the PATH
# Note: Since existing env vars can't be overridden, the PATH variable is used to set the PATH env var in each cmd.
PATH:
sh: |
echo "${PATH}{{.ENV_PATH_SEP}}{{.BIN_DIR}} "
# Include all the tasks at the top level, so they can include tasks in other files. If the tasks are included in the
# sub-files, the tasks are repeated in the 'task --list' output. Including all tasks at the top level prevents this
# duplication.
includes:
init:
# dotenv does not work in included taskfiles.
taskfile: init/Taskfile.yaml
optional: true
dir: ./init
package:
taskfile: package/Taskfile.yaml
optional: true
github:
taskfile: package/GitHub.yaml
optional: true
json:
taskfile: json/Taskfile.yaml
optional: true
filesystem:
taskfile: filesystem/Taskfile.yaml
aliases: [fs]
optional: true
system:
taskfile: system/Taskfile.yaml
optional: true
testing:
taskfile: testing/Taskfile.yaml
optional: true
trmm:
taskfile: trmm/Taskfile.yaml
optional: true
trmm-my-scripts:
taskfile: trmm/My-Scripts.yaml
optional: true
tasks:
donothing: 'true'
list:
cmds:
- cmd: 'task --list'