mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 09:01:39 -05:00
Placate shellcheck
This commit is contained in:
parent
6a0338d132
commit
68aff53e4d
3 changed files with 19 additions and 14 deletions
|
@ -32,7 +32,8 @@ prettierUgly() {
|
|||
tslintUgly() {
|
||||
local acc=""
|
||||
local IFS=$'\n'
|
||||
local tmpdir=$(mktemp -d "tslint.XXXXXXXXX")
|
||||
local tmpdir
|
||||
tmpdir=$(mktemp -d "tslint.XXXXXXXXX")
|
||||
for jsfile in "$@"; do
|
||||
tmpfile="$tmpdir/$jsfile"
|
||||
mkdir -p "$(dirname "$tmpfile")"
|
||||
|
@ -50,5 +51,5 @@ noisy() {
|
|||
acc+=("jsfile")
|
||||
fi
|
||||
done
|
||||
echo ${acc[@]}
|
||||
echo "${acc[@]}"
|
||||
}
|
||||
|
|
|
@ -24,14 +24,16 @@ unlock() {
|
|||
rm "$1"
|
||||
}
|
||||
|
||||
trap "unlock $(git rev-parse --show-toplevel)/.git/index.lock || true" ERR
|
||||
trap 'unlock $(git rev-parse --show-toplevel)/.git/index.lock || true' ERR
|
||||
|
||||
main() {
|
||||
local stagedFiles="$(cachedTSLintFiles)"$'\n'"$(cachedPrettierFiles)"
|
||||
local stagedFiles
|
||||
stagedFiles="$(cachedTSLintFiles)"$'\n'"$(cachedPrettierFiles)"
|
||||
|
||||
if [ -n "$stagedFiles" ]; then
|
||||
# Could use git-update-index --cacheinfo to add a file without creating directories and stuff.
|
||||
local tmpdir=$(mktemp -d "pretty.XXXXXXXXX")
|
||||
local tmpdir
|
||||
tmpdir=$(mktemp -d "pretty.XXXXXXXXX")
|
||||
IFS=$'\n'
|
||||
for file in $stagedFiles; do
|
||||
if cmp -s <(staged "$file") "$file"; then
|
||||
|
@ -47,12 +49,14 @@ main() {
|
|||
echo "WARN: Staged copy of '$file' does not match working copy: only prettifying staged copy."
|
||||
(
|
||||
cd "$tmpdir"
|
||||
mkdir -p $(dirname $file)
|
||||
mkdir -p "$(dirname "$file")"
|
||||
lock ../.git/index.lock
|
||||
tmpfile=$(mktemp "pretty.XXXXXXXXX")
|
||||
case "$file" in
|
||||
*.md | *.css) staged "$file" | prettier --stdin-filepath "$file" > "$file";;
|
||||
*) staged "$file" > "$file"
|
||||
tslint -c ../tslint.json --fix "$file" 2>/dev/null;;
|
||||
*.md | *.css) staged "$file" | prettier --stdin-filepath "$file" > "$tmpfile" && mv "$tmpfile" "$file";;
|
||||
*) staged "$file" > "$tmpfile"
|
||||
tslint -c ../tslint.json --fix "$tmpfile" 2>/dev/null
|
||||
mv "$tmpfile" "$file";;
|
||||
esac
|
||||
chmod --reference="../$file" "$file" # match permissions
|
||||
# Can't hold lock while git add occurs. Hopefully release and reacquire happen fast enough to prevent race.
|
||||
|
|
|
@ -30,14 +30,14 @@ checkRequiredVersions() {
|
|||
colorEcho \
|
||||
'[-] p7zip minimum version '"${MIN_7ZIP_VER}"' required\n' \
|
||||
"alert"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! wine --version 2> /dev/null | grep -q "wine-${MIN_WINE_VER}"; then
|
||||
colorecho \
|
||||
'[-] wine minimum version '"${MIN_WINE_VER}"' required\n' \
|
||||
"alert"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ colorEcho() {
|
|||
local str="$1"
|
||||
local color="${COLOR_GOOD}${COLOR_BOLD}"
|
||||
|
||||
if [ ! -z "$2" ] \
|
||||
if [ -n "$2" ] \
|
||||
&& [ "$(stripWhitespace "$2")" = "alert" ]; then
|
||||
color="${COLOR_BAD}${COLOR_BOLD}"
|
||||
fi
|
||||
|
@ -74,7 +74,7 @@ checkPrerequisite() {
|
|||
printf '%s\n' " - '${bin_name}' found."
|
||||
else
|
||||
printf '%s\n' " - '$1' not found, quitting ..."
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ mainFunction() {
|
|||
colorEcho \
|
||||
'[-] PyInstaller compilation failed, quitting ...\n' \
|
||||
"alert"
|
||||
exit -1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue