File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88- 更新主题配置往返测试:安装只备份外观键,不再错误断言强制切换深色模式
99- 恢复原本没有 ` [desktop] ` 配置段的用户设置时,不再额外写入空段
1010- 热切换读取运行状态时复用 Codex 内置 Node.js,不再依赖系统 ` python3 ` 或执行 ` eval `
11+ - 显式传入的 ` --theme-dir ` 缺少 ` theme.json ` 时立即报错,不再静默回退到内置 demo 主题
1112
1213---
1314
Original file line number Diff line number Diff line change @@ -203,19 +203,18 @@ async function connectCodexTargets(port, timeoutMs) {
203203}
204204
205205async function loadTheme ( themeDir ) {
206- const defaultAssetsRoot = path . join ( root , "assets" ) ;
207- let assetsRoot = defaultAssetsRoot ;
208- if ( themeDir ) {
209- try {
210- await fs . access ( path . join ( themeDir , "theme.json" ) ) ;
211- assetsRoot = themeDir ;
212- } catch ( error ) {
213- if ( error . code !== "ENOENT" ) throw error ;
206+ const assetsRoot = themeDir ?? path . join ( root , "assets" ) ;
207+ const configPath = path . join ( assetsRoot , "theme.json" ) ;
208+ let config ;
209+ try {
210+ config = await fs . readFile ( configPath , "utf8" ) ;
211+ } catch ( error ) {
212+ if ( themeDir && error . code === "ENOENT" ) {
213+ throw new Error ( `Explicit theme directory is missing theme.json: ${ configPath } ` ) ;
214214 }
215+ throw error ;
215216 }
216-
217- const configPath = path . join ( assetsRoot , "theme.json" ) ;
218- const raw = JSON . parse ( await fs . readFile ( configPath , "utf8" ) ) ;
217+ const raw = JSON . parse ( config ) ;
219218 if ( raw . schemaVersion !== 1 || typeof raw . image !== "string" || ! raw . image ) {
220219 throw new Error ( `${ configPath } has an unsupported schema or image field` ) ;
221220 }
Original file line number Diff line number Diff line change @@ -70,6 +70,15 @@ PAYLOAD_JSON="$("$NODE" "$ROOT/scripts/injector.mjs" --check-payload --theme-dir
7070 const value = JSON.parse(process.argv[1]);
7171 if (!value.pass || value.themeName !== "测试主题" || value.imageBytes < 1) process.exit(1);
7272' " $PAYLOAD_JSON "
73+ /bin/mkdir -p " $TMP /missing-theme"
74+ if MISSING_THEME_OUTPUT=" $(
75+ " $NODE " " $ROOT /scripts/injector.mjs" --check-payload --theme-dir " $TMP /missing-theme" 2>&1
76+ ) " ; then
77+ printf ' Explicit theme directory without theme.json unexpectedly passed.\n' >&2
78+ exit 1
79+ fi
80+ /usr/bin/printf ' %s\n' " $MISSING_THEME_OUTPUT " | /usr/bin/grep -F -q \
81+ " Explicit theme directory is missing theme.json: $TMP /missing-theme/theme.json"
7382" $NODE " " $ROOT /scripts/write-theme.mjs" reset-demo --output-dir " $TMP /theme" > /dev/null
7483[ ! -e " $TMP /theme" ]
7584
You can’t perform that action at this time.
0 commit comments