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

vuepress / vuepress-next / 7163313360

11 Dec 2023 05:25AM CUT coverage: 67.837% (-1.3%) from 69.176%
7163313360

Pull #1449

github

web-flow
Merge 4941993a9 into b82d48e1e
Pull Request #1449: feat: remove vuepress-vite and vuepress-webpack package and support --bundler option, close #1446

325 of 462 branches covered (0.0%)

Branch coverage included in aggregate %.

2 of 26 new or added lines in 4 files covered. (7.69%)

1 existing line in 1 file now uncovered.

641 of 962 relevant lines covered (66.63%)

47.76 hits per line

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

4.0
/packages/cli/src/commands/dev/handlePageChange.ts
1
import {
2
  createPage,
3
  preparePageComponent,
4
  preparePageData,
5
  preparePagesComponents,
6
  preparePagesData,
7
  preparePagesRoutes,
8
} from '@vuepress/core'
9
import type { App, Page } from '@vuepress/core'
10

11
/**
12
 * Event handler for page change event
13
 *
14
 * Returns the old page and the new page tuple
15
 */
16
export const handlePageChange = async (
3✔
17
  app: App,
18
  filePath: string,
19
): Promise<[Page, Page] | null> => {
20
  // get page index of the changed file
21
  const pageIndex = app.pages.findIndex((page) => page.filePath === filePath)
×
22
  if (pageIndex === -1) {
×
23
    return null
×
24
  }
25

26
  // get the old page of the changed file
27
  const pageOld = app.pages[pageIndex]
×
28

29
  // create a new page from the changed file
30
  const pageNew = await createPage(app, {
×
31
    filePath,
32
  })
33

34
  // replace the old page with the new page
35
  app.pages.splice(pageIndex, 1, pageNew)
×
36

37
  // prepare page files
38
  await preparePageComponent(app, pageNew)
×
39
  await preparePageData(app, pageNew)
×
40

41
  const isPathChanged = pageOld.path !== pageNew.path
×
42
  const isRouteMetaChanged =
43
    JSON.stringify(pageOld.routeMeta) !== JSON.stringify(pageNew.routeMeta)
×
44

45
  // prepare pages entry if the path is changed
46
  if (isPathChanged) {
×
47
    await preparePagesComponents(app)
×
48
    await preparePagesData(app)
×
49
  }
50

51
  // prepare pages routes if the path or routeMeta is changed
52
  if (isPathChanged || isRouteMetaChanged) {
×
53
    await preparePagesRoutes(app)
×
54
  }
55

56
  return [pageOld, pageNew]
×
57
}
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