Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hernanmd committed Jan 26, 2020
1 parent 48e21aa commit 0ac53dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions libexec/piGitHub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#

# source piUtils.sh
source "${BASH_SOURCE%/*}"/piEnvVars.sh

# Parse and store package names from GitHub API
parseGitHubPkgNames () {
Expand All @@ -20,8 +21,7 @@ downloadGitHubPkgNames () {
local perPage="$2"
# echo "Download JSON file"
local ghPharoTopics="https://api.github.com/search/repositories?per_page=$perPage&page=$pIndex&q=topic:pharo"
[[ -f ${cacheDir}/"$pIndex".js ]] || $dApp "$ghPharoTopics" -O ${cacheDir}/"$pIndex".js
# echo "Done"
[[ -s ${cacheDir}/"$pIndex".js ]] || $dApp "$ghPharoTopics" -O ${cacheDir}/"$pIndex".js
}

readGitHubPkgNames () {
Expand All @@ -31,10 +31,14 @@ readGitHubPkgNames () {
# Split package names into array
while read -rd" "; do fetchedPkgNames+=("$pkg"); done <<< $cpkgs
fetchedPkgNames=($(echo $cpkgs | tr ' ' "\n" ))
#[[ ${#fetchedPkgNames[@]} -eq 0 ]] && return 1
ghPkgNames=( "${ghPkgNames[@]}" "${fetchedPkgNames[@]}" )
# Update package count
ghCurPkgsCount=${#ghPkgNames[@]}
# echo "# of fetchedPkgNames found : "${#fetchedPkgNames[@]}
# echo "# of ghCurPkgsCount found : "${#ghCurPkgsCount[@]}
# echo "# of packages found : "${#ghPkgNames[@]}
# echo " --- "
}

fetchGitHubPkgNames () {
Expand All @@ -50,7 +54,7 @@ fetchGitHubPkgNames () {
parseGitHubPkgCount ${cacheDir}/"$pageIndex.js"
while [ "$ghCurPkgsCount" -lt "$ghPkgCount" ]; do
# Set new download page URL
pageIndex=$(("$pageIndex"+1))
pageIndex=$(($pageIndex+1))
# Download new results
downloadGitHubPkgNames "$pageIndex" "$perPage"
# Parse JSON result into String
Expand All @@ -66,7 +70,7 @@ countgh_packages () {
silentMode=1
downloadGitHubPkgNames "$pageIndex" "$perPage"
parseGitHubPkgCount ${cacheDir}/"$pageIndex.js"
printf "Number of packages in GitHub: %s: \n" "$ghPkgCount"
printf "Number of packages in GitHub: %s\n" "$ghPkgCount"
}

# Install from GitHub
Expand Down
2 changes: 1 addition & 1 deletion libexec/piParseCmdOptions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parseCmdLine () {
listgh | listGH | LISTGH )
silentMode=0
fetchGitHubPkgNames "true"
printf '%s\n' "${ghPkgNames[@]}"
printf "%s\n" "${ghPkgNames[@]}"
;;
listsh | listSH | LISTSH )
silentMode=0
Expand Down

0 comments on commit 0ac53dc

Please sign in to comment.