diff --git a/scripts/fetch-assets.js b/scripts/fetch-assets.js index a39dd94..4816e8d 100644 --- a/scripts/fetch-assets.js +++ b/scripts/fetch-assets.js @@ -4,11 +4,16 @@ // // Архив весит ~34МБ, содержит модели (.glb), текстуры (.png) и скины. // В Git они НЕ лежат — занимают много места и редко меняются. +// +// ES-модуль (в package.json "type": "module"). -const fs = require('fs'); -const path = require('path'); -const https = require('https'); -const { execSync } = require('child_process'); +import fs from 'node:fs'; +import path from 'node:path'; +import https from 'node:https'; +import { execSync } from 'node:child_process'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); const RELEASE_URL = 'https://git.rublox.pro/rublox/studio/releases/download/assets-v1/kubikon-assets.tar.gz'; @@ -68,7 +73,14 @@ async function main() { await download(RELEASE_URL, TMP_TAR); console.log('Распаковка...'); - execSync(`tar -xzf "${TMP_TAR}" -C "${PUBLIC_DIR}"`, { stdio: 'inherit' }); + // На Windows используем native tar.exe из System32 — Git Bash-овский + // BSD-tar ломается на путях с двоеточием (`C:` интерпретируется как + // ssh-хост). На *nix просто `tar` в $PATH. + const tarBin = + process.platform === 'win32' && fs.existsSync('C:\\Windows\\System32\\tar.exe') + ? 'C:\\Windows\\System32\\tar.exe' + : 'tar'; + execSync(`"${tarBin}" -xzf "${TMP_TAR}" -C "${PUBLIC_DIR}"`, { stdio: 'inherit' }); fs.unlinkSync(TMP_TAR); console.log('Готово! Ассеты в public/kubikon-assets/');