Skip to content

Commit

Permalink
chore: added functions to gather information about libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
tristan-greffe committed Mar 12, 2024
1 parent 272a9ba commit 42521e2
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions kash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,29 @@ run_kli() {
fi
cd ~-
}

# Gather information about an librarie
# Defines LIB_INFOS variable as an array. This array contains the lib name & the lib version
# Arg1: the repository root
# NOTE: the results should be extracted using get_lib_xxx functions below.
init_lib_infos() {
local REPO_ROOT="$1"
local LIB_NAME
LIB_NAME=$(node -p -e "require(\"$REPO_ROOT/package.json\").name")
local LIB_VERSION
LIB_VERSION=$(node -p -e "require(\"$REPO_ROOT/package.json\").version")

LIB_INFOS=("$LIB_NAME" "$LIB_VERSION")
}

# Extract lib name from lib infos
# NOTE: requires a call to init_lib_infos first
get_lib_name() {
echo "${LIB_INFOS[0]}"
}

# Extract lib version from lib infos
# NOTE: requires a call to init_lib_infos first
get_lib_version() {
echo "${LIB_INFOS[1]}"
}

0 comments on commit 42521e2

Please sign in to comment.