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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user