How to use the markdown-magic.fsExtra.readdirSync function in markdown-magic

To help you get started, we’ve selected a few markdown-magic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github serverless / blog / validate.js View on Github external
const authorDirectory = path.join(__dirname, 'authors')
const postsDirectory = path.join(__dirname, 'posts')
const dateFormatRegex = /[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])-/g

// Example shape of author data
const authorData = {
  "name": "David Wells",
  "github": "davidwells",
  "avatar": "https://avatars2.githubusercontent.com/u/532272?v=3&s=60",
  "bio": {
    "short": "David Wells is a developer at Serverless, Inc.",
    "long": "David is a Full Stack JavaScript Developer, entrepreneur, past life marketer. Developer @ http://serverless.com "
  }
}

const authorArray = fs.readdirSync(authorDirectory).map((author) =>{
  return author.replace('.json', '')
})


// test author directory
globby(['*', '!node_modules'], {
  cwd: authorDirectory
}).then(paths => {
    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):

markdown-magic

Automatically update markdown files with content from external sources

MIT
Latest version published 3 months ago

Package Health Score

68 / 100
Full package analysis

Similar packages