Skip to content

Commit d6614da

Browse files
authored
fix: fs-extra no longer exports existsSync (#25)
1 parent b20bf24 commit d6614da

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

packages/core/src/htmlPlugin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { cleanUrl, isDirEmpty, loadEnv } from './utils'
55
import { htmlFilter } from './utils/createHtmlFilter'
66
import { mergeConfig } from 'vite'
77
import { parse } from 'node-html-parser'
8-
import { existsSync, readFile, move, remove } from 'fs-extra'
8+
import fsExtra from 'fs-extra'
9+
const { pathExistsSync, readFile, move, remove } = fsExtra
910
import { resolve, dirname, basename } from 'pathe'
1011
import fg from 'fast-glob'
1112
import consola from 'consola'
@@ -270,7 +271,7 @@ export function getHtmlPath(page: PageOption, root: string) {
270271
}
271272

272273
export async function readHtml(path: string) {
273-
if (!existsSync(path)) {
274+
if (!pathExistsSync(path)) {
274275
throw new Error(`html is not exist in ${path}`)
275276
}
276277
return await readFile(path).then((buffer) => buffer.toString())

packages/core/src/utils/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { expand } from 'dotenv-expand'
22
import dotenv from 'dotenv'
33
import { join, dirname } from 'pathe'
4-
import { existsSync, readFileSync, statSync, readdir } from 'fs-extra'
4+
import fsExtra from 'fs-extra'
5+
const { pathExistsSync, readFileSync, statSync, readdir } = fsExtra
56

67
export function loadEnv(
78
mode: string,
@@ -59,7 +60,7 @@ export function lookupFile(
5960
): string | undefined {
6061
for (const format of formats) {
6162
const fullPath = join(dir, format)
62-
if (existsSync(fullPath) && statSync(fullPath).isFile()) {
63+
if (pathExistsSync(fullPath) && statSync(fullPath).isFile()) {
6364
return pathOnly ? fullPath : readFileSync(fullPath, 'utf-8')
6465
}
6566
}

0 commit comments

Comments
 (0)