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

vuepress / vuepress-next / 7184128480

12 Dec 2023 04:07PM CUT coverage: 69.405% (+0.2%) from 69.176%
7184128480

Pull #1314

github

web-flow
Merge e9e22663d into f7d6dde7d
Pull Request #1314: fix(client): avoid updating existing head tags, close #1268

332 of 464 branches covered (0.0%)

Branch coverage included in aggregate %.

13 of 14 new or added lines in 2 files covered. (92.86%)

648 of 948 relevant lines covered (68.35%)

48.83 hits per line

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

4.88
/packages/cli/src/commands/build/createBuild.ts
1
import process from 'node:process'
2
import { createBuildApp } from '@vuepress/core'
3
import type { AppConfig } from '@vuepress/core'
4
import { debug, formatMs, fs, logger, withSpinner } from '@vuepress/utils'
5
import {
6
  loadUserConfig,
7
  resolveAppConfig,
8
  resolveCliAppConfig,
9
  resolveUserConfigConventionalPath,
10
  resolveUserConfigPath,
11
  transformUserConfigToPlugin,
12
} from '../../config/index.js'
13
import type { BuildCommand } from './types.js'
14

15
const log = debug('vuepress:cli/build')
3✔
16

17
export const createBuild =
18
  (defaultAppConfig: Partial<AppConfig>): BuildCommand =>
3✔
19
  async (sourceDir = '.', commandOptions = {}): Promise<void> => {
×
20
    const start = Date.now()
×
21

22
    log(`commandOptions:`, commandOptions)
×
23

24
    if (process.env.NODE_ENV === undefined) {
×
25
      process.env.NODE_ENV = 'production'
×
26
    }
27

28
    // resolve app config from cli options
29
    const cliAppConfig = resolveCliAppConfig(sourceDir, commandOptions)
×
30

31
    // resolve user config file
32
    const userConfigPath = commandOptions.config
×
33
      ? resolveUserConfigPath(commandOptions.config)
34
      : resolveUserConfigConventionalPath(cliAppConfig.source)
35
    log(`userConfigPath:`, userConfigPath)
×
36
    const { userConfig } = await loadUserConfig(userConfigPath)
×
37

38
    // resolve the final app config to use
39
    const appConfig = resolveAppConfig({
×
40
      defaultAppConfig,
41
      cliAppConfig,
42
      userConfig,
43
    })
44
    if (appConfig === null) {
×
45
      return
×
46
    }
47

48
    // create vuepress app
49
    const app = createBuildApp(appConfig)
×
50

51
    // use user-config plugin
52
    app.use(transformUserConfigToPlugin(userConfig, cliAppConfig.source))
×
53

54
    // clean temp and cache
55
    if (commandOptions.cleanTemp === true) {
×
56
      await withSpinner('Cleaning temp')(() => {
×
57
        return fs.remove(app.dir.temp())
×
58
      })
59
    }
60
    if (commandOptions.cleanCache === true) {
×
61
      await withSpinner('Cleaning cache')(() => {
×
62
        return fs.remove(app.dir.cache())
×
63
      })
64
    }
65

66
    // empty dest directory
67
    await fs.emptyDir(app.dir.dest())
×
68

69
    // initialize and prepare
70
    await withSpinner('Initializing and preparing data')(async () => {
×
71
      await app.init()
×
72
      await app.prepare()
×
73
    })
74

75
    // build
76
    await app.build()
×
77

78
    // plugin hook: onGenerated
79
    await app.pluginApi.hooks.onGenerated.process(app)
×
80

81
    logger.success(
×
82
      `VuePress build completed in ${formatMs(Date.now() - start)}!`,
83
    )
84
  }
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