How to use the @statusfy/common.fse.readFile function in @statusfy/common

To help you get started, we’ve selected a few @statusfy/common 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 bazzite / statusfy / packages / @statusfy / core / lib / utils / functions.js View on Github external
const getIncidentsFromProject = async contentDir => {
  const files = await fse.readdir(contentDir);
  const incidentsList = [];

  for (let i = 0; i < files.length; i++) {
    const f = path.resolve(contentDir, files[i]);
    const ext = path.extname(f);
    const fileName = path.basename(f);

    if (ext === ".md") {
      const fileContent = await fse.readFile(f);
      const { data } = grayMatter.parse(fileContent);

      incidentsList.push({
        value: {
          name: fileName,
          path: f
        },
        name: `${fileName} > ${chalk.yellow(data.title)} (${chalk.green(
          new Date(data.date).toUTCString()
        )})`
      });
    }
  }

  return incidentsList;
};
github bazzite / statusfy / packages / @statusfy / core / lib / update-incident.js View on Github external
const getIncidentData = async filePath => {
  const key = `data:${filePath}`;
  let data = cache.get(key);

  if (!data) {
    const fileContent = await fse.readFile(filePath);
    data = grayMatter.parse(fileContent);

    cache.set(key, data);
  }

  return data;
};