From 2c360ac59e845aae9a94c7b54e9928f2f7254399 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 12 Dec 2025 20:38:34 +0800 Subject: [PATCH] feat(theme): add theme config changed logger (#784) --- theme/src/node/loadConfig/ConfigLoader.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/theme/src/node/loadConfig/ConfigLoader.ts b/theme/src/node/loadConfig/ConfigLoader.ts index 5ff6ee6b..ca8e4e7f 100644 --- a/theme/src/node/loadConfig/ConfigLoader.ts +++ b/theme/src/node/loadConfig/ConfigLoader.ts @@ -5,8 +5,9 @@ import EventEmitter from 'node:events' import process from 'node:process' import { deepMerge } from '@pengzhanbo/utils' import { watch } from 'chokidar' +import { colors } from 'vuepress/utils' import { initThemeOptions } from '../config/index.js' -import { perf } from '../utils/index.js' +import { logger, normalizePath, perf } from '../utils/index.js' import { compiler } from './compiler.js' import { findConfigPath } from './findConfigPath.js' @@ -45,16 +46,19 @@ export class ConfigLoader extends EventEmitter { if (!this.configFile) return + const cwd = process.cwd() const watcher = watch([this.configFile, ...this.dependencies], { ignoreInitial: true, - cwd: process.cwd(), + cwd, }) - watcher.on('change', async () => { + watcher.on('change', async (filepath) => { const dependencies = await this.load() watcher.add(dependencies.filter(dep => !this.dependencies.includes(dep))) this.dependencies = [...dependencies] this.emit('change', this.config) + + logger.info(`${colors.gray('theme config')} ${colors.magenta(normalizePath(filepath))} ${colors.gray('is modified.')}`) }) watchers.push(watcher)