1
0
mirror of synced 2025-12-22 03:16:52 -05:00
Files
docs/lib/read-file-contents.js
James M. Greene 9e31597ee4 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
2021-03-10 17:57:10 +00:00

20 lines
644 B
JavaScript

const readFileAsync = require('./readfile-async')
const encodeBracketedParentheses = require('./encode-bracketed-parentheses')
const fm = require('./frontmatter')
/**
* Read only the frontmatter from file
*/
module.exports = async function fmfromf (filepath, languageCode) {
let fileContent = await readFileAsync(filepath, 'utf8')
fileContent = encodeBracketedParentheses(fileContent)
// TODO remove this when crowdin-support issue 66 has been resolved
if (languageCode !== 'en' && fileContent.includes(': verdadero')) {
fileContent = fileContent.replace(': verdadero', ': true')
}
return fm(fileContent, { filepath })
}