chore: update check script

This commit is contained in:
GyDi 2022-02-18 23:49:39 +08:00
parent c046a1993e
commit a13d4698be
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084

View File

@ -50,7 +50,7 @@ async function resolveSidecar() {
const sidecarFile = `clash-${host}${ext}`; const sidecarFile = `clash-${host}${ext}`;
const sidecarPath = path.join(sidecarDir, sidecarFile); const sidecarPath = path.join(sidecarDir, sidecarFile);
if (!(await fs.pathExists(sidecarDir))) await fs.mkdir(sidecarDir); await fs.mkdirp(sidecarDir);
if (await fs.pathExists(sidecarPath)) return; if (await fs.pathExists(sidecarPath)) return;
// download sidecar // download sidecar
@ -59,7 +59,7 @@ async function resolveSidecar() {
const tempZip = path.join(tempDir, binInfo.zipfile); const tempZip = path.join(tempDir, binInfo.zipfile);
const tempExe = path.join(tempDir, binInfo.exefile); const tempExe = path.join(tempDir, binInfo.exefile);
if (!(await fs.pathExists(tempDir))) await fs.mkdir(tempDir); await fs.mkdirp(tempDir);
if (!(await fs.pathExists(tempZip))) await downloadFile(binInfo.url, tempZip); if (!(await fs.pathExists(tempZip))) await downloadFile(binInfo.url, tempZip);
if (binInfo.zip === "zip") { if (binInfo.zip === "zip") {
@ -96,8 +96,10 @@ async function resolveMmdb() {
const url = const url =
"https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb"; "https://github.com/Dreamacro/maxmind-geoip/releases/latest/download/Country.mmdb";
const resPath = path.join(cwd, "src-tauri", "resources", "Country.mmdb"); const resDir = path.join(cwd, "src-tauri", "resources");
const resPath = path.join(resDir, "Country.mmdb");
if (await fs.pathExists(resPath)) return; if (await fs.pathExists(resPath)) return;
await fs.mkdirp(resDir);
await downloadFile(url, resPath); await downloadFile(url, resPath);
} }
@ -118,5 +120,5 @@ async function downloadFile(url, path) {
} }
/// main /// main
resolveSidecar(); resolveSidecar().catch(console.error);
resolveMmdb(); resolveMmdb().catch(console.error);