Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli): watch mode without config file #1042

Merged
merged 1 commit into from May 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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