这是indexloc提供的服务,不要输入任何密码
Skip to content

cleanup: replace fs-extra with node:fs #1216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@
"@rollup/plugin-json": "6.1.0",
"@swc/core": "1.7.26",
"@types/debug": "4.1.12",
"@types/fs-extra": "11.0.4",
"@types/node": "22.5.5",
"@types/resolve": "1.20.6",
"bumpp": "^9.5.2",
"flat": "6.0.1",
"fs-extra": "11.2.0",
"postcss": "8.4.47",
"postcss-simple-vars": "7.0.1",
"prettier": "3.3.3",
Expand Down
46 changes: 0 additions & 46 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions test/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import fs from 'node:fs'
import fsp from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { expect } from 'vitest'
import execa from 'execa'
import fs from 'fs-extra'
import { glob } from 'tinyglobby'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
Expand Down Expand Up @@ -35,8 +36,12 @@ export async function run(

// Write entry files on disk
await Promise.all(
Object.keys(files).map((name) => {
return fs.outputFile(path.resolve(testDir, name), files[name], 'utf8')
Object.keys(files).map(async (name) => {
const filePath = path.resolve(testDir, name)
const parentDir = path.dirname(filePath)
// Thanks to `recursive: true`, this doesn't fail even if the directory already exists.
await fsp.mkdir(parentDir, { recursive: true })
return fsp.writeFile(filePath, files[name], 'utf8')
}),
)

Expand Down Expand Up @@ -69,7 +74,7 @@ export async function run(
logs,
outDir: path.resolve(testDir, 'dist'),
getFileContent(filename: string) {
return fs.readFile(path.resolve(testDir, filename), 'utf8')
return fsp.readFile(path.resolve(testDir, filename), 'utf8')
},
}
}
Expand Down