Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Jan 27, 2022
2 parents 71b5323 + d6614da commit af57412
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/htmlPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { cleanUrl, isDirEmpty, loadEnv } from './utils'
import { htmlFilter } from './utils/createHtmlFilter'
import { mergeConfig } from 'vite'
import { parse } from 'node-html-parser'
import { existsSync, readFile, move, remove } from 'fs-extra'
import fsExtra from 'fs-extra'
const { pathExistsSync, readFile, move, remove } = fsExtra
import { resolve, dirname, basename } from 'pathe'
import fg from 'fast-glob'
import consola from 'consola'
Expand Down Expand Up @@ -270,7 +271,7 @@ export function getHtmlPath(page: PageOption, root: string) {
}

export async function readHtml(path: string) {
if (!existsSync(path)) {
if (!pathExistsSync(path)) {
throw new Error(`html is not exist in ${path}`)
}
return await readFile(path).then((buffer) => buffer.toString())
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { expand } from 'dotenv-expand'
import dotenv from 'dotenv'
import { join, dirname } from 'pathe'
import { existsSync, readFileSync, statSync, readdir } from 'fs-extra'
import fsExtra from 'fs-extra'
const { pathExistsSync, readFileSync, statSync, readdir } = fsExtra

export function loadEnv(
mode: string,
Expand Down Expand Up @@ -59,7 +60,7 @@ export function lookupFile(
): string | undefined {
for (const format of formats) {
const fullPath = join(dir, format)
if (existsSync(fullPath) && statSync(fullPath).isFile()) {
if (pathExistsSync(fullPath) && statSync(fullPath).isFile()) {
return pathOnly ? fullPath : readFileSync(fullPath, 'utf-8')
}
}
Expand Down

0 comments on commit af57412

Please sign in to comment.