Skip to content

Commit

Permalink
fix(cli): watch mode without config file (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed May 31, 2022
1 parent d01b8c2 commit b74a76d
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions packages/cli/src/index.ts
Expand Up @@ -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)
Expand Down

0 comments on commit b74a76d

Please sign in to comment.