1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/lib/read-file-contents.js
Jason Etcovitch 53d8e60959 Add a test for non-English rendering (#17593)
* Throw in some code that should fail a test

* Remove read-frontmatter behavior

* Unskip the test that would catch this

* Remove the throw to pass the test
2021-02-02 18:14:39 +00:00

20 lines
626 B
JavaScript

const fs = require('fs')
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 fs.promises.readFile(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 })
}