Skip to content

Commit f6161b0

Browse files
committed
fix: fs/promises usage
1 parent 65e2c05 commit f6161b0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

init/clean.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFile, writeFile } from 'fs/promises'
1+
import { promises as fs } from 'fs'
22
import { fileURLToPath } from 'url'
33

44
import del from 'del'
@@ -17,7 +17,7 @@ export const cleanRepo = async function () {
1717

1818
// Remove `npm run init` in `package.json` and all `devDependencies`.
1919
const cleanPackageJson = async function () {
20-
const content = await readFile(PACKAGE_JSON, 'utf8')
20+
const content = await fs.readFile(PACKAGE_JSON, 'utf8')
2121
const { scripts, dependencies, devDependencies, ...packageJson } =
2222
JSON.parse(content)
2323

@@ -31,7 +31,7 @@ const cleanPackageJson = async function () {
3131
}
3232

3333
const contentA = JSON.stringify(packageJsonA, null, 2)
34-
await writeFile(PACKAGE_JSON, contentA)
34+
await fs.writeFile(PACKAGE_JSON, contentA)
3535
}
3636

3737
// Remove devDependencies used only for initialization

init/template.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { readFile, writeFile } from 'fs/promises'
1+
import { promises as fs } from 'fs'
22
import { fileURLToPath } from 'url'
33

44
import fastGlob from 'fast-glob'
@@ -19,9 +19,9 @@ const addPackageRoot = function (path) {
1919
}
2020

2121
const applyTemplate = async function (file, variables) {
22-
const content = await readFile(file, 'utf8')
22+
const content = await fs.readFile(file, 'utf8')
2323
const contentA = replaceVariables(content, variables)
24-
await writeFile(file, contentA)
24+
await fs.writeFile(file, contentA)
2525
}
2626

2727
const replaceVariables = function (content, variables) {

0 commit comments

Comments
 (0)