Skip to content

Commit

Permalink
revert: revert the commit of modify routes
Browse files Browse the repository at this point in the history
This reverts commit 8c00955.
  • Loading branch information
BeADre committed Jul 19, 2021
1 parent 8c00955 commit d26c420
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions packages/varlet-cli/src/compiler/compileRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SITE_PC_ROUTES,
SRC_DIR,
} from '../shared/constant'
import { pathExistsSync, readdir, readdirSync, writeFile, ensureFileSync, readFileSync } from 'fs-extra'
import { pathExistsSync, readdir, readdirSync, writeFile } from 'fs-extra'
import { resolve } from 'path'
import { isMD } from '../shared/fsUtils'

Expand Down Expand Up @@ -80,8 +80,6 @@ export async function findRootDocsPaths(): Promise<string[]> {
export async function buildMobileSiteRoutes() {
const examplePaths: string[] = await findExamplePaths()

await ensureFileSync(SITE_MOBILE_ROUTES)

const routes = examplePaths.map(
(examplePath) => `
{
Expand All @@ -91,21 +89,17 @@ export async function buildMobileSiteRoutes() {
`
)

const routeContent = readFileSync(SITE_MOBILE_ROUTES, 'utf-8')
const newContent = `export default [\
await writeFile(
SITE_MOBILE_ROUTES,
`export default [\
${routes.join(',')}
]`

if (routeContent !== newContent) {
await writeFile(SITE_MOBILE_ROUTES, newContent)
}
)
}

export async function buildPcSiteRoutes() {
const [componentDocsPaths, rootDocsPaths] = await Promise.all([findComponentDocsPaths(), findRootDocsPaths()])

await ensureFileSync(SITE_PC_ROUTES)

const componentDocsRoutes = componentDocsPaths.map(
(componentDocsPath) => `
{
Expand All @@ -126,12 +120,10 @@ export async function buildPcSiteRoutes() {
`
)

const routeContent = readFileSync(SITE_PC_ROUTES, 'utf-8')
const newContent = `export default [\
await writeFile(
SITE_PC_ROUTES,
`export default [\
${[...componentDocsRoutes, rootDocsRoutes].join(',')}
]`

if (routeContent !== newContent) {
await writeFile(SITE_PC_ROUTES, newContent)
}
)
}

0 comments on commit d26c420

Please sign in to comment.