mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
install: allow region select via env var
This commit is contained in:
1 file changed
+4
@@ -582,11 +582,15 @@ ${nixConfBase}`);
|
|||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
try {
|
try {
|
||||||
|
if (process.env.REGION) {
|
||||||
|
if (process.env.REGION !== 'CN') CN = false;
|
||||||
|
} else {
|
||||||
console.log('Getting IP info to find best mirror:');
|
console.log('Getting IP info to find best mirror:');
|
||||||
const res = await fetch('https://ipinfo.io', { headers: { accept: 'application/json' } }).then((r) => r.json());
|
const res = await fetch('https://ipinfo.io', { headers: { accept: 'application/json' } }).then((r) => r.json());
|
||||||
delete res.readme;
|
delete res.readme;
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.country !== 'CN') CN = false;
|
if (res.country !== 'CN') CN = false;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
console.log('Cannot find the best mirror. Fallback to default.');
|
console.log('Cannot find the best mirror. Fallback to default.');
|
||||||
|
|||||||
Reference in new issue
Block a user