File tree 2 files changed +45
-1
lines changed 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 3
3
# This file is sourced into ~/.bashrc
4
4
# Add any alias you would like here
5
5
6
- alias lint-starter-scripts=' find "$GITPOD_REPO_ROOT/.gp" -type d \( -name node_modules \) -prune -false -o -name "* .sh" -exec shellcheck -x -P "$GITPOD_REPO_ROOT/.gp" {} \; '
6
+ alias lint-starter-scripts=' f(){ bash "$GITPOD_REPO_ROOT" /.gp/bash/lint-scripts .sh "$1"; unset -f f; }; f '
7
7
# Updates all passwords related to phpmyadmin from values set in .starter.env
8
8
# Requires .starter.env to have all phpmyadmin related keys set with values
9
9
# Empty string value will break the script
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ # Copyright © 2021 Apolo Pena
5
+ #
6
+ # lint-scripts.sh
7
+ # Description:
8
+ # Finds all .sh files that the starter uses, runs them through shellcheck and
9
+ # outputs a simple success summary or just the standard output if shellcheck
10
+ # finds anything that needs attention.
11
+ #
12
+ # Note:
13
+ # Pass in an optional -v or --verbose if you would like to output a list of the files being checked
14
+
15
+ path () {
16
+ if [[ -z $GITPOD_REPO_ROOT ]]; then
17
+ echo ' .gp'
18
+ else
19
+ echo " $GITPOD_REPO_ROOT /.gp"
20
+ fi
21
+ }
22
+
23
+ list_all_scripts () {
24
+ find " $( path) " -type d \( -name node_modules \) -prune -false -o -name " *.sh"
25
+ }
26
+
27
+ script_total () {
28
+ list_all_scripts | wc -l
29
+ }
30
+
31
+ main () {
32
+ local total result
33
+ if [[ $1 == ' -v' || $1 == ' --verbose' ]]; then
34
+ echo -e " \e[38;5;87mRunning all starter scripts through shellcheck\e[0m"
35
+ echo -ne " \e[38;5;45m"
36
+ list_all_scripts; echo -ne " \e[0m"
37
+ fi
38
+ total=$( script_total)
39
+ result=$( find " $( path) " -type d \( -name node_modules \) -prune -false -o -name " *.sh" -exec shellcheck -x -P " $( path) " {} \; | tee >( wc -l) )
40
+ [[ $result == 0 ]] && echo -e " \e[38;5;76mSUCCESS:\e[0m \e[38;5;40mall \e[0;36m$total \e[0m \e[38;5;40mscripts in the system passed the shellcheck.\e[0m" && exit
41
+ find " $( path) " -type d \( -name node_modules \) -prune -false -o -name " *.sh" -exec shellcheck -x -P " $( path) " {} \;
42
+ }
43
+
44
+ main " $1 "
You can’t perform that action at this time.
0 commit comments