How to use the @statusfy/common.path.extname 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 / content / database.js View on Github external
const exists = await fse.pathExists(dirPath);

  if (!exists) {
    logger.warn(`Content Directory not found: ${dirPath}`);
  } else {
    try {
      const files = (await readdirP(dirPath)).map(f => path.join(dirPath, f));

      for (let i = 0; i < files.length; i++) {
        const filePath = files[i];
        const isFile = (await statP(filePath)).isFile();

        if (
          isFile &&
          path.extname(filePath) === ".md" &&
          path.basename(filePath).toLowerCase() !== "readme.md"
        ) {
          const fileName = path.relative(dirPath, filePath);
          const fileContent = (await readFileP(filePath)).toString("utf8");
          const incident = new Incident(fileContent, fileName).getData();

          if (!incident.modified) {
            try {
              incident.modified = new Date(
                getGitLastUpdatedTimeStamp(filePath)
              ).toISOString();
            } catch (error) {
              incident.modified = null;
            }
          }
github bazzite / statusfy / packages / @statusfy / core / lib / config / load.js View on Github external
function parseConfig(filePath) {
  const extension = path.extname(filePath);
  let data;

  logger.info(
    `Reading configuration from ${chalk.yellow(`config${extension}`)}`
  );

  if (extension !== ".js") {
    const content = fse.readFileSync(filePath, "utf-8");

    if (extension === ".yml") {
      data = yaml.parse(content);
    } else if (extension === ".toml") {
      data = toml.parse(content);
    }
  } else {
    data = require(filePath);
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()
        )})`
      });
    }