• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vuepress / vuepress-next / 3860590913

pending completion
3860590913

Pull #1228

github

GitHub
Merge b04c6dafe into b4e313bb7
Pull Request #1228: feat(core): add markdownEnv to Page

325 of 468 branches covered (69.44%)

Branch coverage included in aggregate %.

683 of 1003 relevant lines covered (68.1%)

42.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.7
/packages/cli/src/config/resolveAppConfig.ts
1
import type { AppConfig } from '@vuepress/core'
2
import { ensureEndingSlash, ensureLeadingSlash } from '@vuepress/shared'
3
import { colors, isChildPath, logger } from '@vuepress/utils'
4

5
/**
6
 * Resolve app config according to:
7
 *
8
 * - default options
9
 * - cli options
10
 * - user config file
11
 */
12
export const resolveAppConfig = ({
3✔
13
  defaultAppConfig,
14
  cliAppConfig,
15
  userConfig,
16
}: {
17
  defaultAppConfig: Partial<AppConfig>
18
  cliAppConfig: Partial<AppConfig>
19
  userConfig: Partial<AppConfig>
20
}): AppConfig | null => {
21
  const appConfig = {
×
22
    // allow setting default app config via `cli()`
23
    // for example, set different default bundler in `vuepress` and `vuepress-vite` package
24
    ...defaultAppConfig,
25
    // use cli options to override config file
26
    ...userConfig,
27
    ...cliAppConfig,
28
  } as AppConfig
29

30
  if (appConfig.bundler === undefined || appConfig.theme === undefined) {
×
31
    logger.error(
×
32
      `${colors.magenta('bundler')} and ${colors.magenta('theme')} are required`
33
    )
34
    return null
×
35
  }
36

37
  if (
×
38
    appConfig.base &&
×
39
    !(appConfig.base.startsWith('/') && appConfig.base.endsWith('/'))
×
40
  ) {
41
    const rawBase = appConfig.base
×
42
    appConfig.base = ensureLeadingSlash(ensureEndingSlash(rawBase)) as
×
43
      | '/'
44
      | `/${string}/`
45
    logger.warn(
×
46
      `${colors.magenta('base')} should start and end with a slash (/),` +
47
        ` so it has been normalized from ${colors.magenta(rawBase)}` +
48
        ` to ${colors.magenta(appConfig.base)}`
49
    )
50
  }
51

52
  if (appConfig.dest && isChildPath(appConfig.source, appConfig.dest)) {
×
53
    logger.warn(
×
54
      `${colors.magenta('dest')} directory would be emptied during build,` +
55
        ` so we fallback it to the default directory for the safety of your source files`
56
    )
57
    delete appConfig.dest
×
58
  }
59

60
  return appConfig
×
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc