From b74a76d7d830ccb4fbc39f77533ba121b6766e23 Mon Sep 17 00:00:00 2001 From: Johann Schopplich Date: Tue, 31 May 2022 14:55:54 +0200 Subject: [PATCH] fix(cli): watch mode without config file (#1042) --- packages/cli/src/index.ts | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 29d9a118e9..0d9dfdb241 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -92,26 +92,25 @@ export async function build(_options: CliOptions) { ignored, }) - if (configSources.length) { + if (configSources.length) watcher.add(configSources) - watcher.on('all', async (type, file) => { - if (configSources.includes(file)) { - uno.setConfig((await loadConfig()).config) - consola.info(`${cyan(basename(file))} changed, setting new config`) - } - else { - consola.log(`${green(type)} ${dim(file)}`) - - if (type.startsWith('unlink')) - fileCache.delete(file) - else - fileCache.set(file, await fs.readFile(file, 'utf8')) - } - - debouncedBuild() - }) - } + watcher.on('all', async (type, file) => { + if (configSources.includes(file)) { + uno.setConfig((await loadConfig()).config) + consola.info(`${cyan(basename(file))} changed, setting new config`) + } + else { + consola.log(`${green(type)} ${dim(file)}`) + + if (type.startsWith('unlink')) + fileCache.delete(file) + else + fileCache.set(file, await fs.readFile(file, 'utf8')) + } + + debouncedBuild() + }) } await generate(options)