Add the automatic replacement of domestic source function of pake-cli
This commit is contained in:
14
bin/helpers/rust.ts
vendored
14
bin/helpers/rust.ts
vendored
@@ -2,9 +2,17 @@ import { IS_WIN } from '@/utils/platform.js';
|
||||
import ora from 'ora';
|
||||
import shelljs from 'shelljs';
|
||||
import { shellExec } from '../utils/shell.js';
|
||||
import {isChinaDomain} from '@/utils/ip_addr.js'
|
||||
|
||||
const RustInstallScriptFocMac =
|
||||
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
|
||||
const is_china = isChinaDomain("sh.rustup.rs");
|
||||
let RustInstallScriptFocMac = "";
|
||||
if (is_china) {
|
||||
RustInstallScriptFocMac =
|
||||
'export RUSTUP_DIST_SERVER="https://rsproxy.cn" && export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup" && curl --proto "=https" --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh';
|
||||
} else {
|
||||
RustInstallScriptFocMac =
|
||||
"curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y";
|
||||
}
|
||||
const RustInstallScriptForWin = 'winget install --id Rustlang.Rustup';
|
||||
|
||||
export async function installRust() {
|
||||
@@ -21,5 +29,5 @@ export async function installRust() {
|
||||
}
|
||||
|
||||
export function checkRustInstalled() {
|
||||
return shelljs.exec('rustc --version', { silent: true }).code === 0;
|
||||
return shelljs.exec('source "$HOME/.cargo/env" && rustc --version', { silent: true }).code === 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user