Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
paths.forEach((file) => {
const fp = path.join(authorDirectory, file)
if (file.match(/\.json/)) {
const author = fs.readFileSync(fp, 'utf8')
const valid = hasSameProps(authorData, JSON.parse(author))
if (!valid) {
const msg = `${file} has missing value in author profile.
Author data must match (if no value applies use false):
${JSON.stringify(authorData, null, 2)}`
throw new Error(msg)
}
} else {
// not json throw error
throw new Error(`${file} file type not allowed in authors directory ${file}`);
}
})
paths.forEach((file) => {
const postPath = path.join(postsDirectory, file)
if (file.match(dateFormatRegex)) {
const post = fs.readFileSync(postPath, 'utf8')
const postData = yml(post).data
let msg
if (isEmptyObject(postData)) {
msg = `no yaml found in post or YAML is malformed! Please update ${file}`
throw new Error(msg)
}
if (!postData.title) {
msg = `No title found in post YAML
Please update ${file}
---- The description format is -----
title: "My 50-60 character Human & Keyword Friendly title"