diff --git a/scripts/deploy-nas.cjs b/scripts/deploy-nas.cjs index e3e1b2a..ef4edd7 100644 --- a/scripts/deploy-nas.cjs +++ b/scripts/deploy-nas.cjs @@ -40,10 +40,26 @@ if (isWin) { // SSH 경로: NAS_SSH_TARGET이 설정된 경우 항상 우선 if (sshTarget) { - console.log(`Deploying via SSH → ${sshTarget}:${sshPath}`); - const sshCmd = sshPort ? `ssh -p ${sshPort}` : "ssh"; + // 제어문자·줄바꿈 제거 (잘못된 export/copy-paste 대비) + const cleanTarget = sshTarget.replace(/[\r\n\t]/g, "").trim(); + const cleanPath = sshPath.replace(/[\r\n\t]/g, "").trim(); + const cleanPort = sshPort ? sshPort.replace(/\D/g, "").trim() : ""; + + if (!cleanTarget) { + console.error("NAS_SSH_TARGET 값이 비어있습니다. .env.local 또는 환경변수를 확인하세요."); + printSshHint(); + process.exit(1); + } + if (cleanPort && !/^\d{1,5}$/.test(cleanPort)) { + console.error(`NAS_SSH_PORT 값이 잘못됐습니다: "${sshPort}" → 숫자만 입력하세요.`); + process.exit(1); + } + + const sshCmd = cleanPort ? `ssh -p ${cleanPort}` : "ssh"; + console.log(`Deploying via SSH → ${cleanTarget}:${cleanPath}`); + console.log(`SSH command: ${sshCmd}`); execSync( - `rsync -r --delete --delete-delay -e "${sshCmd}" ${src}/ ${sshTarget}:${sshPath}`, + `rsync -r --delete --delete-delay -e "${sshCmd}" ${src}/ ${cleanTarget}:${cleanPath}`, { stdio: "inherit" } ); process.exit(0);