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:
Joshua Chen 2022-04-17 12:50:09 +08:00 committed by GitHub
parent 674a77f02d
commit 200009008b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 27 additions and 33 deletions

View file

@ -27,12 +27,8 @@ type PackageJsonFile = {
async function getPackagesJsonFiles(): Promise<PackageJsonFile[]> {
const files = await Globby('packages/*/package.json');
return Promise.all(
files.map(async (file) => ({
file,
content: JSON.parse(await fs.readFile(file, 'utf8')),
})),
files.map((file) => fs.readJSON(file).then((content) => ({file, content}))),
);
}