mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-02-13 03:52:43 +00:00
feat: include old stashed tweaks to x-asdf-cleanup
This commit is contained in:
@@ -165,23 +165,45 @@ trim_whitespace() {
|
|||||||
# Function to process each .tool-versions file
|
# Function to process each .tool-versions file
|
||||||
# Usage: process_file "file"
|
# Usage: process_file "file"
|
||||||
# Output: "tool version"
|
# Output: "tool version"
|
||||||
process_file() {
|
process_tool_versions_file() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
awk '{for (i=2; i<=NF; i++) print $1, $i}' "$file"
|
awk '{for (i=2; i<=NF; i++) print $1, $i}' "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to find .tool-versions files using fd
|
# Function to find version files using fd
|
||||||
# It will exclude directories defined in EXCLUDE_PATTERNS
|
# It will exclude directories defined in EXCLUDE_PATTERNS
|
||||||
# Usage: find_tool_versions_files
|
# Usage: find_version_files "file"
|
||||||
# Output: List of .tool-versions files found
|
# Output: List of files found
|
||||||
find_tool_versions_files() {
|
find_version_files() {
|
||||||
local fd_command="fd --base-directory $BASE_DIR --glob '.tool-versions' --hidden"
|
local FILE="$1"
|
||||||
|
local fd_command="fd --base-directory $BASE_DIR --glob '$FILE' --hidden"
|
||||||
for pattern in "${EXCLUDE_PATTERNS[@]}"; do
|
for pattern in "${EXCLUDE_PATTERNS[@]}"; do
|
||||||
fd_command="$fd_command --exclude $pattern"
|
fd_command="$fd_command --exclude $pattern"
|
||||||
done
|
done
|
||||||
eval "$fd_command"
|
eval "$fd_command"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Helper to find_version_files function to find .tool-versions files
|
||||||
|
# Usage: find_tool_versions_files
|
||||||
|
# Output: List of .tool-versions files found
|
||||||
|
find_tool_versions_files() {
|
||||||
|
echo find_version_files ".tool-versions"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper to find_version_files function to find .nvmrc files
|
||||||
|
# Usage: find_nvmrc_files
|
||||||
|
# Output: List of .nvmrc files found
|
||||||
|
find_nvmrc_files() {
|
||||||
|
echo find_version_files ".nvmrc"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper to find_version_files function to find .python-version files
|
||||||
|
# Usage: find_python_version_files
|
||||||
|
# Output: List of .python-version files found
|
||||||
|
find_python_version_files() {
|
||||||
|
echo find_version_files ".python-version"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to read and combine the contents of all found files.
|
# Function to read and combine the contents of all found files.
|
||||||
# It will store the tool names and versions in an associative array.
|
# It will store the tool names and versions in an associative array.
|
||||||
# The key is "name version" and the value is 1.
|
# The key is "name version" and the value is 1.
|
||||||
@@ -193,7 +215,7 @@ read_defined_versions() {
|
|||||||
for file in $files; do
|
for file in $files; do
|
||||||
while read -r name version; do
|
while read -r name version; do
|
||||||
defined_versions["$name $version"]=1
|
defined_versions["$name $version"]=1
|
||||||
done < <(process_file "$BASE_DIR/$file")
|
done < <(process_tool_versions_file "$BASE_DIR/$file")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user