How to use the @statusfy/common.fse.pathExists 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 readFileIncidents = async dirPath => {
  const allIncidents = [];

  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"
        ) {
github bazzite / statusfy / packages / @statusfy / core / lib / update-incident.js View on Github external
const { incident, resolved, severity, affectedsystems, confirm } = answers;

    try {
      if (confirm) {
        const modified = dates.parse().toISOString();
        const locales = config.locales.map(l => l.code);
        const updatedFiles = [];

        for (let j = 0; j < locales.length; j++) {
          const locale = locales[j];
          const localeIncidentPath = path.join(
            contentDir,
            config.defaultLocale !== locale ? locale : "",
            incident.name
          );
          const exists = await fse.pathExists(localeIncidentPath);

          if (exists) {
            try {
              const data = await getIncidentData(localeIncidentPath);
              const newMatter = {
                ...data.data,
                modified,
                severity,
                affectedsystems,
                resolved
              };

              const content = generateIncident(
                newMatter,
                data.content,
                config.content.frontMatterFormat
github bazzite / statusfy / packages / @statusfy / core / lib / delete-incident.js View on Github external
inquirer.prompt(questions).then(async answers => {
    const { incident, confirm } = answers;

    try {
      if (confirm) {
        const locales = config.locales.map(l => l.code);
        const deletedFiles = [];

        for (let j = 0; j < locales.length; j++) {
          const locale = locales[j];
          const localeIncidentPath = path.join(
            contentDir,
            config.defaultLocale !== locale ? locale : "",
            incident.name
          );
          const exists = await fse.pathExists(localeIncidentPath);

          if (exists) {
            try {
              await fse.remove(localeIncidentPath);
              deletedFiles.push(localeIncidentPath);
            } catch (error) {
              logger.error(error);
            }
          } else {
            logger.warn(`This file couldn't be found:\n${localeIncidentPath}`);
          }
        }

        if (deletedFiles.length > 0) {
          const prefix =
            deletedFiles.length === 1