Created
April 24, 2024 02:15
-
-
Save zmzlois/b875cef441dece6942445124559f2544 to your computer and use it in GitHub Desktop.
npm-for-monorepo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function genme() { | |
| local package=$1 | |
| local output=$(pnpm search --json ${package} | jq -r 'map( { name, description, command: ("pnpm add " + .name) } )') | |
| local fzf_input=$(echo "${output}" | jq -r '.[] | "\(.name) - \(.description)"') | |
| local selected=$(echo "$fzf_input" | fzf) | |
| # If nothing was selected, exit | |
| if [[ -z "$selected" ]]; then | |
| echo "No package selected." | |
| return | |
| fi | |
| local selected_name=$(echo "$selected" | cut -d' ' -f1) | |
| local command=$(echo "${output}" | jq -r --arg PACKAGE "$selected_name" '.[] | select(.name == $PACKAGE) | .command') | |
| echo "You selected: $command" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment