mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 17:22:35 +02:00
refactor: prefer fs.readJSON over readFile.then(JSON.parse) (#7186)
* refactor: prefer fs.readJSON over readFile.then(JSON.parse) * refactor: use promises
This commit is contained in:
parent
674a77f02d
commit
200009008b
9 changed files with 27 additions and 33 deletions
|
@ -103,8 +103,7 @@ function isValidGitRepoUrl(gitRepoUrl: string) {
|
|||
}
|
||||
|
||||
async function updatePkg(pkgPath: string, obj: {[key: string]: unknown}) {
|
||||
const content = await fs.readFile(pkgPath, 'utf-8');
|
||||
const pkg = JSON.parse(content);
|
||||
const pkg = await fs.readJSON(pkgPath);
|
||||
const newPkg = Object.assign(pkg, obj);
|
||||
|
||||
await fs.outputFile(pkgPath, `${JSON.stringify(newPkg, null, 2)}\n`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue