How to use the markdown-magic.globby.sync 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 DavidWells / netlify-functions-workshop / _scripts / docs.js View on Github external
}).map((file) => {
        const filePath = path.join(lessonsPath, file)
        const examples = globby.sync([
          // `!node_modules`,
          `${filePath}/**/**.md`,
          `!${filePath}/node_modules/**/**`,
          `!${filePath}/**/node_modules/**/**`,
          // `!${filePath}/node_modules/**/**.md`,
          // `!${filePath}/**/node_modules/**/**.md`,
        ])

        // console.log('examples', examples)
        // console.log('filePath', filePath)
        // process.exit(1)
        let md = `### ${formatName(file)}

${generateTable(examples)}
`
        return md
github netlify / cli / scripts / generateCommandData.js View on Github external
module.exports = function generateCommandData() {
  const commandsPath = path.join(__dirname, '..', 'src/commands')
  const netlifyDevPath = path.join(__dirname, '..', 'node_modules/netlify-dev-plugin/src/commands')
  // console.log('commandsPath', commandsPath)
  const commands = globby.sync([`${commandsPath}/**/**.js`, `${netlifyDevPath}/**/**.js`])

  const allCommands = commands.map(file => {
    let cmd = {}
    try {
      cmd = require(file)
    } catch (e) {
      throw e
    }
    const command = commandFromPath(file)
    const parentCommand = command.split(':')[0]
    const parent = command === parentCommand ? true : false
    return {
      command: command,
      commandGroup: parentCommand,
      isParent: parent,
      path: file,
github netlify / cli / scripts / docs.js View on Github external
markdownMagic(markdownFiles, config, () => {
  /* Post process the docs */
  const processedDocs = globby.sync(['../docs/**/**.md'])
  processedDocs.map(f => {
    const filePath = path.resolve(f)
    const fileContents = fs.readFileSync(filePath, 'utf8')

    // Fix garbage chalk output
    const updatedContents = fileContents.replace(/\[92m/, '').replace(/\[39m/, '')
    fs.writeFileSync(filePath, updatedContents)
  })
  console.log('Docs updated!')
})
github DavidWells / netlify-functions-workshop / _scripts / docs.js View on Github external
GENERATE_LESSONS_STEPS(content, options, instance) {
      // console.log('instance.outputDir', instance.outputDir)

      // debug single file
      // if (instance.outputDir !== "_instructor/events/step-functions") {
      //   return content
      // }
      const lessonFiles = globby.sync(['**', '!node_modules'], {
        cwd: instance.outputDir
      })
      const jsRegex = /\/\* Step([\s\S]*?)\*\//g
      const ymlRegex = / *?# Step([\s\S]*?) #\n*?/g
      const htmlRegex = / *?\<\!-- Step([\s\S]*?) ?--\>\n*?/g
      var matches = []
      if (lessonFiles) {
        lessonFiles.map((f) => {
          const filePath = path.join(instance.outputDir, f)
          if (fs.lstatSync(filePath).isDirectory()) {
            // skip dirs
            return
          }
          const fileContents = fs.readFileSync(filePath, 'utf8')
          const fileType = path.extname(f)
github DavidWells / serverless-workshop / docs.js View on Github external
GENERATE_LESSONS_STEPS(content, options, instance) {

      //console.log('instance.outputDir', instance.outputDir)

      // debug single file
      // if (instance.outputDir !== "_instructor/events/step-functions") {
      //   return content
      // }
      const lessonFiles = globby.sync(['**', '!node_modules'], {
        cwd: instance.outputDir
      })
      const jsRegex = /\/\* Step([\s\S]*?)\*\//g
      const ymlRegex = / *?# Step([\s\S]*?) #\n*?/g
      const htmlRegex = / *?\<\!-- Step([\s\S]*?) ?--\>\n*?/g
      var matches = []
      if (lessonFiles) {
        lessonFiles.map((f) => {
          const filePath = path.join(instance.outputDir, f)
          if (fs.lstatSync(filePath).isDirectory()) {
            // skip dirs
            return;
          }
          const fileContents = fs.readFileSync(filePath, 'utf8')
          const fileType = path.extname(f)
          var regex = jsRegex
github DavidWells / serverless-workshop / postDocs.js View on Github external
const path = require('path')
const chalk = require('chalk')
const markdownMagic = require('markdown-magic')
const globby = require('markdown-magic').globby

console.log('Post process lesson files')

const removeComments = / *?\<\!-- ([\s\S]*?) ?--\>\n\n*?/g

const directories = [
  'lessons-code-complete/**/**.md',
  'lessons/**/**.md',
  '!node_modules'
]

const lessonFiles = globby.sync(directories)

if (lessonFiles) {
  console.log(chalk.yellow('Removing comments from student files'))
  lessonFiles.map((f) => {
    const filePath = path.resolve(f)
    // console.log('filePath', filePath)
    const fileContents = fs.readFileSync(filePath, 'utf8')
    //console.log(fileContents)
    const fileType = path.extname(f)

    const updatedContents = fileContents.replace(removeComments, '')
    fs.writeFileSync(filePath, updatedContents)
    //console.log('updatedContents', updatedContents)
  })
  console.log(chalk.green('All Done!'))
}
github serverless / examples / generate-readme.js View on Github external
SERVERLESS_EXAMPLE_TABLE() {
      const examples = globby.sync(['**/package.json', '!node_modules/**/package.json', '!**/node_modules/**/package.json', '!package.json']);
      // Make table header
      let md = '| Example | Runtime  |\n';
      md += '|:--------------------------- |:-----|\n';
      examples.forEach((example) => {
        const data = JSON.parse(fs.readFileSync(example, 'utf8'));
        const dirname = path.dirname(example);
        const exampleUrl = `https://github.com/serverless/examples/tree/master/${dirname}`;
        const runtime = getRuntime(dirname);
        const description = (data.description) ? `<br> ${data.description}` : '';
        // add table rows
        md += `| [${formatPluginName(data.name)}](${exampleUrl}) ${description} | ${runtime} |\n`;
      });

      return md;
    },
    /*
github DavidWells / serverless-workshop / docs.js View on Github external
}).map((file) => {
        const filePath = path.join(lessonsPath, file)
        const examples = globby.sync([`${filePath}/**/**.md`]);

        let md = `### ${formatName(file)}

${generateTable(examples)}
`
        return md
      })

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