1
0
mirror of synced 2025-12-21 02:46:50 -05:00

Use promisified fs.readFile instead of fs.promises.readFile (#18204)

* Create a readFileAsync wrapper module

* Use the readFileAsync wrapper module instead of fs.promises.readFile

* Fix require path in test
This commit is contained in:
James M. Greene
2021-03-10 11:57:10 -06:00
committed by GitHub
parent c3b6ace1b6
commit 9e31597ee4
14 changed files with 51 additions and 41 deletions

View File

@@ -2,6 +2,7 @@ const { execSync } = require('child_process')
const { get, set } = require('lodash')
const fs = require('fs')
const path = require('path')
const readFileAsync = require('../lib/readfile-async')
const fm = require('../lib/frontmatter')
const matter = require('gray-matter')
const chalk = require('chalk')
@@ -23,7 +24,7 @@ const fixableYmlProps = ['date']
const loadAndValidateContent = async (path, schema) => {
let fileContents
try {
fileContents = await fs.promises.readFile(path, 'utf8')
fileContents = await readFileAsync(path, 'utf8')
} catch (e) {
console.error(e.message)
return null