use normalize path

This commit is contained in:
SrGooglo 2024-02-02 11:56:09 +01:00
parent a6372f3358
commit 46c77a15b0
3 changed files with 16 additions and 14 deletions

View File

@ -48,6 +48,7 @@
"request": "^2.88.2", "request": "^2.88.2",
"rimraf": "^5.0.5", "rimraf": "^5.0.5",
"unzipper": "^0.10.14", "unzipper": "^0.10.14",
"upath": "^2.0.1",
"uuid": "^9.0.1", "uuid": "^9.0.1",
"which": "^4.0.0", "which": "^4.0.0",
"winreg": "^1.2.5" "winreg": "^1.2.5"

View File

@ -1,16 +1,15 @@
import path from "node:path" import path from "node:path"
import fs from "node:fs" import fs from "node:fs"
import os from "node:os"
import ChildProcess from "node:child_process" import ChildProcess from "node:child_process"
import upath from "upath"
import sendToRender from "../../utils/sendToRender" import sendToRender from "../../utils/sendToRender"
import Vars from "../../vars" import Vars from "../../vars"
const gitCMD = fs.existsSync(Vars.git_path) ? `${Vars.git_path}` : "git" const gitCMD = fs.existsSync(Vars.git_path) ? `${Vars.git_path}` : "git"
export default async (manifest, step) => { export default async (manifest, step) => {
const final_path = path.resolve(manifest.install_path, step.path) const final_path = upath.normalizeSafe(path.resolve(manifest.install_path, step.path))
if (!fs.existsSync(final_path)) { if (!fs.existsSync(final_path)) {
fs.mkdirSync(final_path, { recursive: true }) fs.mkdirSync(final_path, { recursive: true })
@ -21,17 +20,18 @@ export default async (manifest, step) => {
statusText: `Cloning ${step.url}`, statusText: `Cloning ${step.url}`,
}) })
console.log(`USING GIT BIN>`, gitCMD)
console.log(`[${manifest.id}] steps.git_clone() | Cloning ${step.url}...`) console.log(`[${manifest.id}] steps.git_clone() | Cloning ${step.url}...`)
const command = `${gitCMD} clone --recurse-submodules --remote-submodules ${step.url} ${final_path}` const command = `${gitCMD} clone --depth ${step.depth ?? 1} --recurse-submodules --remote-submodules ${step.url} ${final_path}`
//fs.mkdirSync(final_path, { recursive: true })
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
ChildProcess.exec( ChildProcess.exec(
command, command,
{ {
shell: true, shell: true,
cwd: final_path,
}, },
(error, out) => { (error, out) => {
if (error) { if (error) {

View File

@ -1,18 +1,19 @@
import path from "node:path" import path from "node:path"
import upath from "upath"
global.OS_USERDATA_PATH = path.resolve( global.OS_USERDATA_PATH = upath.normalizeSafe(path.resolve(
process.env.APPDATA || process.env.APPDATA ||
(process.platform == "darwin" ? process.env.HOME + "/Library/Preferences" : process.env.HOME + "/.local/share"), (process.platform == "darwin" ? process.env.HOME + "/Library/Preferences" : process.env.HOME + "/.local/share"),
) ))
global.RUNTIME_PATH = path.join(global.OS_USERDATA_PATH, "rs-bundler") global.RUNTIME_PATH = upath.normalizeSafe(path.join(global.OS_USERDATA_PATH, "rs-bundler"))
global.PACKAGES_PATH = path.join(global.RUNTIME_PATH, "packages") global.PACKAGES_PATH = upath.normalizeSafe(path.join(global.RUNTIME_PATH, "packages"))
global.BINARIES_PATH = path.resolve(global.RUNTIME_PATH, "bin_lib") global.BINARIES_PATH = upath.normalizeSafe(path.resolve(global.RUNTIME_PATH, "bin_lib"))
global.LOCAL_DB = path.join(global.RUNTIME_PATH, "local_db.json") global.LOCAL_DB = upath.normalizeSafe(path.join(global.RUNTIME_PATH, "local_db.json"))
global.SEVENZIP_PATH = path.resolve(global.BINARIES_PATH, "7z-bin", process.platform === "win32" ? "7za.exe" : "7za") global.SEVENZIP_PATH = upath.normalizeSafe(path.resolve(global.BINARIES_PATH, "7z-bin", process.platform === "win32" ? "7za.exe" : "7za"))
global.GIT_PATH = path.resolve(global.BINARIES_PATH, "git-bin", "bin", process.platform === "win32" ? "git.exe" : "git") global.GIT_PATH = upath.normalizeSafe(path.resolve(global.BINARIES_PATH, "git-bin", "bin", process.platform === "win32" ? "git.exe" : "git"))
export default { export default {
binaries_path: global.BINARIES_PATH, binaries_path: global.BINARIES_PATH,