1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/lib/read-file-contents.js
Mike Surowiec b4608a86d8 fix: remove usage of readFileAsync (#28053)
* fix: remove usage of readFileAsync

* fix: use same import style

* fix: update tests

Co-authored-by: Peter Bengtsson <mail@peterbe.com>
2022-06-01 14:49:30 +00:00

16 lines
393 B
JavaScript

import fs from 'fs/promises'
import encodeBracketedParentheses from './encode-bracketed-parentheses.js'
import fm from './frontmatter.js'
/**
* Read only the frontmatter from file
*/
export default async function fmfromf(filepath) {
let fileContent = await fs.readFile(filepath, 'utf8')
fileContent = encodeBracketedParentheses(fileContent)
return fm(fileContent, { filepath })
}