chore(style): add shebang, set bash strict mode, create function
[webi-installers/.git] / dotenv-linter / install.sh
1 #!/bin/bash
2 set -e
3 set -u
4
5 function __init_dotenv_linter() {
6
7     #########################
8     # Install dotenv-linter #
9     #########################
10
11     # Every package should define these 6 variables
12     pkg_cmd_name="dotenv-linter"
13
14     pkg_dst_cmd="$HOME/.local/bin/dotenv-linter"
15     pkg_dst="$pkg_dst_cmd"
16
17     pkg_src_cmd="$HOME/.local/opt/dotenv-linter-v$WEBI_VERSION/bin/dotenv-linter"
18     pkg_src_dir="$HOME/.local/opt/dotenv-linter-v$WEBI_VERSION"
19     pkg_src="$pkg_src_cmd"
20
21     # pkg_install must be defined by every package
22     pkg_install() {
23         # ~/.local/opt/dotenv-linter-v0.99.9/bin
24         mkdir -p "$(dirname $pkg_src_cmd)"
25
26         # mv ./dotenv-linter-*/dotenv-linter ~/.local/opt/dotenv-linter-v0.99.9/bin/dotenv-linter
27         mv ./dotenv-linter "$pkg_src_cmd"
28     }
29
30     # pkg_get_current_version is recommended, but (soon) not required
31     pkg_get_current_version() {
32         # 'dotenv-linter --version' has output in this format:
33         #       dotenv-linter 0.99.9 (rev abcdef0123)
34         # This trims it down to just the version number:
35         #       0.99.9
36         echo $(dotenv-linter --version 2> /dev/null | head -n 1 | cut -d ' ' -f 2)
37     }
38
39 }
40
41 __init_dotenv_linter