* Create a readFileAsync wrapper module * Use the readFileAsync wrapper module instead of fs.promises.readFile * Fix require path in test
20 lines
644 B
JavaScript
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 })
|
|
}
|