-
-
Save Fatpandac/a01bb465b0fafde4f1ebdb86579233f9 to your computer and use it in GitHub Desktop.
Change npm source
This file contains 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
#!/usr/bin/env bash | |
if ! type fzf >/dev/null 2>&1; then | |
echo "请先安装 fzf" | |
exit 0 | |
fi | |
declare -A source | |
source["npm"]="https://registry.npmjs.org/" | |
source["taobao"]="https://registry.npm.taobao.org/" | |
source["2dfire"]="http://npm.2dfire.net/" | |
listAll="" | |
for key in "${!source[@]}"; do | |
listAll+="$key " | |
done | |
listAll=`echo "$listAll" | tr ' ' '\n'` | |
selected=`printf "$listAll" | fzf` | |
if [[ -z $selected ]]; then | |
exit 0 | |
fi | |
echo "npm set registry ${source[$selected]}" | |
npm set registry ${source[$selected]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment