diff --git a/cn/dev-mirrors.json b/cn/dev-mirrors.json index b172483e..50f14221 100644 --- a/cn/dev-mirrors.json +++ b/cn/dev-mirrors.json @@ -9,7 +9,7 @@ }, "cargo": { "china": "sparse+https://rsproxy.cn/index/", - "official": "sparse+https://index.crates.io/" + "official": "" }, "go": { "china": "https://goproxy.cn,direct", diff --git a/cn/lib/dev-mirror.sh b/cn/lib/dev-mirror.sh index f15889fc..37bb981e 100644 --- a/cn/lib/dev-mirror.sh +++ b/cn/lib/dev-mirror.sh @@ -26,11 +26,9 @@ cn_dm_set_line() { mkdir -p "${file%/*}" touch "$file" - if grep -qE "$match" "$file"; then - sed -i -E "s|$match.*|$line|" "$file" - else - echo "$line" >> "$file" - fi + grep -vE "$match" "$file" > "$file.omarchycn-tmp" || true + printf '%s\n' "$line" >> "$file.omarchycn-tmp" + mv "$file.omarchycn-tmp" "$file" } cn_dm_get_npm() { grep -sE '^registry=' "$HOME/.npmrc" | cut -d= -f2- || true; } @@ -71,8 +69,14 @@ cn_dm_set_cargo() { mkdir -p "${f%/*}" touch "$f" sed -i '/^# OmarchyCN dev-mirror begin$/,/^# OmarchyCN dev-mirror end$/d' "$f" - if [[ -n $url ]]; then - cat >> "$f" <&2 + return 1 + fi + cat >> "$f" < "$HOME/.gemrc" <&2 + return 1 + fi + cat > "$f" <