mirror of
https://github.com/ragestudio/relic.git
synced 2025-06-09 10:34:18 +00:00
extract
This commit is contained in:
parent
2f8f735710
commit
c1d2c1b064
@ -4,6 +4,8 @@ import os from "node:os"
|
|||||||
import ChildProcess from "node:child_process"
|
import ChildProcess from "node:child_process"
|
||||||
import { pipeline as streamPipeline } from "node:stream/promises"
|
import { pipeline as streamPipeline } from "node:stream/promises"
|
||||||
|
|
||||||
|
import { extractFull } from "node-7z"
|
||||||
|
|
||||||
import got from "got"
|
import got from "got"
|
||||||
|
|
||||||
function resolveDestBin(pre, post) {
|
function resolveDestBin(pre, post) {
|
||||||
@ -23,8 +25,14 @@ function resolveDestBin(pre, post) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const sevenzip_exec = path.resolve(global.RUNTIME_PATH, "7z-bin", process.platform === "win32" ? "7za.exe" : "7za")
|
const binariesPath = path.resolve(global.RUNTIME_PATH, "bin_lib")
|
||||||
const git_exec = path.resolve(global.RUNTIME_PATH, "git", process.platform === "win32" ? "git.exe" : "git")
|
|
||||||
|
if (!fs.existsSync(binariesPath)) {
|
||||||
|
fs.mkdirSync(binariesPath, { recursive: true })
|
||||||
|
}
|
||||||
|
|
||||||
|
const sevenzip_exec = path.resolve(binariesPath, "7z-bin", process.platform === "win32" ? "7za.exe" : "7za")
|
||||||
|
const git_exec = path.resolve(binariesPath, "git", process.platform === "win32" ? "git.exe" : "git")
|
||||||
|
|
||||||
if (!fs.existsSync(sevenzip_exec)) {
|
if (!fs.existsSync(sevenzip_exec)) {
|
||||||
global.win.webContents.send("initializing_text", "Downloading 7z binaries...")
|
global.win.webContents.send("initializing_text", "Downloading 7z binaries...")
|
||||||
@ -50,15 +58,19 @@ async function main() {
|
|||||||
|
|
||||||
console.log(`Downloading git binaries...`)
|
console.log(`Downloading git binaries...`)
|
||||||
|
|
||||||
|
const tempPath = path.resolve(binariesPath, "git-bundle.7z")
|
||||||
|
|
||||||
fs.mkdirSync(path.resolve(global.RUNTIME_PATH, "git"), { recursive: true })
|
fs.mkdirSync(path.resolve(global.RUNTIME_PATH, "git"), { recursive: true })
|
||||||
|
|
||||||
let url = resolveDestBin(`https://storage.ragestudio.net/rstudio/binaries/git`, "git.7z")
|
let url = resolveDestBin(`https://storage.ragestudio.net/rstudio/binaries/git`, "git.7z")
|
||||||
|
|
||||||
await streamPipeline(
|
await streamPipeline(
|
||||||
got.stream(url),
|
got.stream(url),
|
||||||
fs.createWriteStream(git_exec)
|
fs.createWriteStream(tempPath)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await extractFull(tempPath, path.resolve(global.RUNTIME_PATH, "git"))
|
||||||
|
|
||||||
if (os.platform() !== "win32") {
|
if (os.platform() !== "win32") {
|
||||||
ChildProcess.execSync("chmod +x " + git_exec)
|
ChildProcess.execSync("chmod +x " + git_exec)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user