From e93f02ca76f30b86d513946413545d6f5525e649 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Thu, 30 May 2024 13:44:46 -0300 Subject: [PATCH] reorganize post install --- postinstall.cjs | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/postinstall.cjs b/postinstall.cjs index 31899dca..12daee06 100644 --- a/postinstall.cjs +++ b/postinstall.cjs @@ -5,12 +5,7 @@ const { spawnSync } = require("node:child_process"); const exec = util.promisify(require("node:child_process").exec); -const downloadAria2WindowsAndLinux = async () => { - if (fs.existsSync("aria2")) { - console.log("Aria2 already exists, skipping download..."); - return; - } - +const setupAria2OnWindowsAndLinux = async () => { const file = process.platform === "win32" ? "aria2-1.37.0-win-64bit-build1.zip" @@ -48,12 +43,7 @@ const downloadAria2WindowsAndLinux = async () => { }); }; -const copyAria2Macos = async () => { - if (fs.existsSync("aria2")) { - console.log("Aria2 already exists, skipping..."); - return; - } - +const setupAria2OnMacos = async () => { console.log("Checking if aria2 is installed..."); const isAria2Installed = spawnSync("which", ["aria2c"]).status; @@ -69,15 +59,26 @@ const copyAria2Macos = async () => { await exec(`cp $(which aria2c) aria2/aria2c`); }; +const setupAria2 = () => { + if (fs.existsSync("aria2")) { + console.log("Aria2 already exists, skipping..."); + return; + } + + if (process.platform == "darwin") { + setupAria2OnMacos(); + } else { + setupAria2OnWindowsAndLinux(); + } + + console.log("Aria2 setup finished"); +}; + +setupAria2(); + if (process.platform === "win32") { fs.copyFileSync( "node_modules/ps-list/vendor/fastlist-0.3.0-x64.exe", "fastlist.exe" ); } - -if (process.platform == "darwin") { - copyAria2Macos(); -} else { - downloadAria2WindowsAndLinux(); -}