const { execSync } = require("child_process"); const fs = require("fs"); const isWin = process.platform === "win32"; const src = "dist"; const dstWin = "Z:\\docker\\webpage\\frontend\\"; const dstMac = "/Volumes/gahusb.synology.me/docker/webpage/frontend/"; const dst = isWin ? dstWin : dstMac; if (!fs.existsSync(src)) { console.error("dist not found. Run build first."); process.exit(1); } if (!fs.existsSync(dst)) { console.error("NAS path not found. Check mount: " + dst); process.exit(1); } if (isWin) { const cmd = 'powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference=\\"Stop\\"; $src=\\"dist\\"; $dst=\\"Z:\\\\docker\\\\webpage\\\\frontend\\\\\\"; if(!(Test-Path $src)){ throw \\"dist not found. Run build first.\\" }; if(!(Test-Path $dst)){ throw \\"NAS drive not found. Check Z: mapping.\\" }; $log = Join-Path (Get-Location) \\"robocopy.log\\"; robocopy $src $dst /MIR /R:1 /W:1 /E /NFL /NDL /NP /V /TEE /LOG:$log; $rc = $LASTEXITCODE; if($rc -ge 8){ Write-Host \\"robocopy failed with code $rc. See $log\\"; exit $rc } else { exit 0 }"'; execSync(cmd, { stdio: "inherit" }); } else { execSync(`rsync -av --delete --delete-delay --inplace ${src}/ ${dst}`, { stdio: "inherit", }); }