Skip to content

Commit

Permalink
fix(cli): load config twice (#1714)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris <1633711653@qq.com>
Co-authored-by: Frozen FIsh <76603360+sudongyuer@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 9, 2022
1 parent 18c2388 commit 1a11f48
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/cli/src/index.ts
Expand Up @@ -5,7 +5,6 @@ import consola from 'consola'
import { cyan, dim, green } from 'colorette'
import { debounce } from 'perfect-debounce'
import { toArray } from '@unocss/core'
import { loadConfig } from '@unocss/config'
import type { SourceCodeTransformerEnforce, UserConfig } from '@unocss/core'
import { version } from '../package.json'
import { createContext } from '../../shared-integration/src/context'
Expand All @@ -31,10 +30,14 @@ export async function build(_options: CliOptions) {

const cwd = _options.cwd || process.cwd()
const options = await resolveOptions(_options)
const { config, sources: configSources } = await loadConfig(cwd, options.config)

const ctx = createContext<UserConfig>(config, defaultConfig)
async function loadConfig() {
const ctx = createContext<UserConfig>(options.config, defaultConfig)
const configSources = (await ctx.updateRoot(cwd)).sources
return { ctx, configSources }
}

const { ctx, configSources } = await loadConfig()
const files = await fg(options.patterns, { cwd, absolute: true })
await Promise.all(
files.map(async (file) => {
Expand Down

0 comments on commit 1a11f48

Please sign in to comment.