Skip to content

Commit

Permalink
cleanup: replace fs-extra with node:fs (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
pralkarz authored Sep 19, 2024
1 parent 52b4e07 commit e36f400
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 52 deletions.
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

0 comments on commit e36f400

Please sign in to comment.