17 lines
466 B
Bash
17 lines
466 B
Bash
function donpm() {
|
|
if [ ! -f "package.json" ]; then
|
|
gum log --level error "package.json not found in the current directory"
|
|
return 1
|
|
fi
|
|
|
|
OPTIONS=$(jq -r '.scripts|to_entries[]|((.key))' package.json)
|
|
OPTIONS+="\n🛑 Cancel"
|
|
SELECTION=$(echo $OPTIONS | gum choose --header "Choose a script to run")
|
|
|
|
if [[ "$SELECTION" == "🛑 Cancel" ]]; then
|
|
gum log --level info "Execution was cancelled"
|
|
return 1
|
|
else
|
|
npm run $SELECTION
|
|
fi
|
|
}
|