How to use vfile - 2 common examples

To help you get started, we’ve selected a few vfile 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 jondot / celeste / src / runner.js View on Github external
const opts = {
    logger,
    publishers: config.publishers,
    plugins: config.plugins,
    processors: config.processors,
    fetch: createCachedFetch({})
  }
  const processor = createProcessor(opts)
  const publisher = createPublisher(opts)
  const files = await globby(args.input)
  // eslint-disable-next-line
  for (const path of files) {
    try {
      // eslint-disable-next-line
      const contents: string = (await fs.readFile(path)).toString()
      const vf = vfile({ path, contents })

      // eslint-disable-next-line
      const res = await processor(vf)
      // console.log(report(res))

      // eslint-disable-next-line
      await publisher(vf)
    } catch (err) {
      logger.log({
        type: 'celeste',
        level: 'error',
        payload: { err, stack: err.stack }
      })
    }
  }
  return logger
github patternplate / patternplate / packages / server / source / application / routes / docs.js View on Github external
async function getDoc(id) {
  if (!id) {
    return null;
  }

  const file = resolve(id);

  if (!await exists(file)) {
    return null;
  }

  return vfile({
    path: path.posix.relative("./patterns", resolve(id)),
    contents: escapeHtml(await sander.readFile(file))
  });
}

vfile

Virtual file format for text processing

MIT
Latest version published 4 months ago

Package Health Score

82 / 100
Full package analysis

Popular vfile functions