Skip to content

Commit 6c68421

Browse files
authored
chore(build): replace node:fs repeated import (#13467)
1 parent c7d3207 commit 6c68421

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

scripts/build.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ nr build core --formats cjs
1818

1919
import fs from 'node:fs'
2020
import { parseArgs } from 'node:util'
21-
import { existsSync, readFileSync } from 'node:fs'
2221
import path from 'node:path'
2322
import { brotliCompressSync, gzipSync } from 'node:zlib'
2423
import pico from 'picocolors'
@@ -163,15 +162,15 @@ async function build(target) {
163162
? `packages-private`
164163
: `packages`
165164
const pkgDir = path.resolve(`${pkgBase}/${target}`)
166-
const pkg = JSON.parse(readFileSync(`${pkgDir}/package.json`, 'utf-8'))
165+
const pkg = JSON.parse(fs.readFileSync(`${pkgDir}/package.json`, 'utf-8'))
167166

168167
// if this is a full build (no specific targets), ignore private packages
169168
if ((isRelease || !targets.length) && pkg.private) {
170169
return
171170
}
172171

173172
// if building a specific format, do not remove dist.
174-
if (!formats && existsSync(`${pkgDir}/dist`)) {
173+
if (!formats && fs.existsSync(`${pkgDir}/dist`)) {
175174
fs.rmSync(`${pkgDir}/dist`, { recursive: true })
176175
}
177176

@@ -234,7 +233,7 @@ async function checkSize(target) {
234233
* @returns {Promise<void>}
235234
*/
236235
async function checkFileSize(filePath) {
237-
if (!existsSync(filePath)) {
236+
if (!fs.existsSync(filePath)) {
238237
return
239238
}
240239
const file = fs.readFileSync(filePath)

0 commit comments

Comments
 (0)