Skip to content

Commit 857d51f

Browse files
authored
refactor: use builtin fs/promises instead of fs-extra (#58)
1 parent e300d07 commit 857d51f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@
6363
"@adonisjs/env": "^4.2.0-0",
6464
"@poppinss/chokidar-ts": "^4.1.0-1",
6565
"@poppinss/cliui": "^6.1.1-1",
66-
"@types/fs-extra": "^11.0.1",
6766
"@types/picomatch": "^2.3.0",
6867
"cpy": "^9.0.1",
6968
"execa": "^7.0.0",
70-
"fs-extra": "^11.1.0",
7169
"get-port": "^6.1.2",
7270
"picomatch": "^2.3.1",
7371
"slash": "^5.0.0"

src/bundler.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import fs from 'fs-extra'
1110
import slash from 'slash'
1211
import copyfiles from 'cpy'
1312
import type tsStatic from 'typescript'
13+
import fs from 'node:fs/promises'
1414
import { fileURLToPath } from 'node:url'
1515
import { join, relative } from 'node:path'
1616
import { cliui, type Logger } from '@poppinss/cliui'
@@ -56,7 +56,7 @@ export class Bundler {
5656
* Cleans up the build directory
5757
*/
5858
async #cleanupBuildDirectory(outDir: string) {
59-
await fs.remove(outDir)
59+
await fs.rm(outDir, { recursive: true, force: true, maxRetries: 5 })
6060
}
6161

6262
/**
@@ -125,13 +125,19 @@ export class Bundler {
125125
* Copies .adonisrc.json file to the destination
126126
*/
127127
async #copyAdonisRcFile(outDir: string) {
128-
const existingContents = await fs.readJSON(join(this.#cwdPath, '.adonisrc.json'))
128+
const existingContents = JSON.parse(
129+
await fs.readFile(join(this.#cwdPath, '.adonisrc.json'), 'utf-8')
130+
)
129131
const compiledContents = Object.assign({}, existingContents, {
130132
typescript: false,
131133
lastCompiledAt: new Date().toISOString(),
132134
})
133135

134-
await fs.outputJSON(join(outDir, '.adonisrc.json'), compiledContents, { spaces: 2 })
136+
await fs.mkdir(outDir, { recursive: true })
137+
await fs.writeFile(
138+
join(outDir, '.adonisrc.json'),
139+
JSON.stringify(compiledContents, null, 2) + '\n'
140+
)
135141
}
136142

137143
/**

0 commit comments

Comments
 (0)