feat: 날씨 유형 그림 8장·미리보기 그림 9장, 한글 사용자 폴더에서 그림 도구가 멈추던 것 고침
- 유형 그림 8장(800×800 webp): 임시 그림을 Codex 로 그린 그림으로 교체 — 같은 토끼가 유형별 날씨 장면에 - 미리보기 그림 9장(1200×630 png)을 새 그림으로 다시 만듦 - 그림 프롬프트 admin/image-prompts/weather-type.json 추가 (다시 그려도 같은 그림체) - admin/scripts/bin.mjs: 윈도우에서 프로그램 위치를 PATH 로 직접 찾음 (where 출력은 경로의 한글이 깨짐), .cmd 가 .exe 를 가리키는 경우(npm 으로 깐 claude)도 부름 - admin/scripts/bin.mjs removeDir: 경로에 한글이 있으면 rmSync(recursive) 가 Node 를 꺼뜨려(종료 코드 127) 그림 한 장만 만들고 끝나던 것 — 하나씩 지우게 - admin 테스트 추가 (admin 에서 npm test)
This commit is contained in:
1 parent
4fc61d6c02
commit
11a7a270ff
23 files changed
+147
-17
No files matched your search
+24
-11
@@ -1,6 +1,6 @@
|
||||
// 외부 프로그램(크롬·claude·codex·ffmpeg) 위치와 부르는 법. 맥·윈도우 둘 다에서 돌게 한 곳에 모은다.
|
||||
import { execFileSync } from 'node:child_process'
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { existsSync, readdirSync, readFileSync, rmdirSync, unlinkSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
|
||||
const WIN = process.platform === 'win32'
|
||||
@@ -15,24 +15,37 @@ export const CHROME =
|
||||
|
||||
/**
|
||||
* execFile 로 부를 [실행 파일, ...앞 인자]. CLAUDE_BIN·CODEX_BIN 환경변수로 바꿀 수 있다.
|
||||
* 윈도우에서 npm 으로 깐 CLI 는 .cmd 라 shell 없이는 못 부르므로(인자 따옴표가 깨짐) .cmd 가 가리키는 .js 를 node 로 직접 부른다.
|
||||
* 윈도우에서 npm 으로 깐 CLI 는 .cmd 라 shell 없이는 못 부르므로(인자 따옴표가 깨짐) .cmd 가 가리키는 .js 를 node 로, .exe 는 그대로 직접 부른다.
|
||||
*/
|
||||
export function cli(name) {
|
||||
const override = process.env[`${name.toUpperCase()}_BIN`]
|
||||
if (override) return [override]
|
||||
if (!WIN) return [name]
|
||||
let hits = []
|
||||
try {
|
||||
hits = execFileSync('where', [name], { encoding: 'utf8' }).split(/\r?\n/).filter(Boolean)
|
||||
} catch {
|
||||
throw new Error(`${name} 을(를) 찾지 못했어요. 설치했는지 보고, ${name.toUpperCase()}_BIN 환경변수로 실행 파일 경로를 알려 주세요.`)
|
||||
}
|
||||
// PATH 를 직접 훑는다: `where` 의 출력은 윈도우 코드 페이지(한국어 CP949)라, 경로에 한글이 있으면(사용자 폴더 이름) utf8 로 읽을 때 깨진다
|
||||
const dirs = (process.env.PATH ?? '').split(';').filter(Boolean)
|
||||
const hits = dirs.flatMap((dir) => ['.exe', '.cmd'].map((ext) => join(dir, name + ext))).filter((p) => existsSync(p))
|
||||
if (hits.length === 0) throw new Error(`${name} 을(를) 찾지 못했어요. 설치했는지 보고, ${name.toUpperCase()}_BIN 환경변수로 실행 파일 경로를 알려 주세요.`)
|
||||
const exe = hits.find((p) => p.toLowerCase().endsWith('.exe'))
|
||||
if (exe) return [exe]
|
||||
const shim = hits.find((p) => p.toLowerCase().endsWith('.cmd'))
|
||||
const js = shim && readFileSync(shim, 'utf8').match(/%dp0%\\([^"]+?\.js)/)?.[1]
|
||||
if (!js) throw new Error(`${name} 실행 파일(${hits.join(', ')})을 부를 수 없어요. ${name.toUpperCase()}_BIN 환경변수로 .exe 경로를 알려 주세요.`)
|
||||
return [process.execPath, join(dirname(shim), js)]
|
||||
// .cmd 의 실제로 부르는 줄("…" %*)은 옆 node_modules 의 .js(codex) 나 .exe(claude) 를 가리킨다
|
||||
const target = shim && readFileSync(shim, 'utf8').match(/%dp0%\\([^"]+?\.(?:js|exe))"\s+%\*/)?.[1]
|
||||
if (!target) throw new Error(`${name} 실행 파일(${hits.join(', ')})을 부를 수 없어요. ${name.toUpperCase()}_BIN 환경변수로 .exe 경로를 알려 주세요.`)
|
||||
const path = join(dirname(shim), target)
|
||||
return target.endsWith('.exe') ? [path] : [process.execPath, path]
|
||||
}
|
||||
|
||||
/**
|
||||
* 폴더를 안의 것까지 지운다.
|
||||
* rmSync(dir, { recursive: true }) 는 윈도우에서 경로에 한글이 있으면(사용자 폴더 이름이 한글인 PC 의 임시 폴더) Node 가 오류도 없이 꺼져서(v24.12, 종료 코드 127) 하나씩 지운다
|
||||
*/
|
||||
export function removeDir(dir) {
|
||||
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
||||
const path = join(dir, entry.name)
|
||||
if (entry.isDirectory()) removeDir(path)
|
||||
else unlinkSync(path)
|
||||
}
|
||||
rmdirSync(dir)
|
||||
}
|
||||
|
||||
/** png → jpg (품질 높게) */
|
||||
|
||||
Reference in new issue
Block a user