How to use the @statusfy/common.fse.remove 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 / client / modules / statusfy / index.js View on Github external
locale.code
        );

        const rssPath = path.join(
          this.options.generate.dir,
          "feeds",
          `incidents.${locale.code}.xml`
        );
        const atomPath = path.join(
          this.options.generate.dir,
          "feeds",
          `incidents.${locale.code}.atom`
        );

        // Ensure no feed file exists
        await fse.remove(rssPath);
        await fse.ensureFile(rssPath);
        await fse.remove(atomPath);
        await fse.ensureFile(atomPath);

        await fse.writeFile(rssPath, feeds.rss());
        await fse.writeFile(atomPath, feeds.atom());

        logger.success(`Generated /feeds/incidents.${locale.code}.xml`);
        logger.success(`Generated /feeds/incidents.${locale.code}.atom`);
      }
    }

    /* Calendars */
    if (
      statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.icalendar
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.icalendar
    ) {
      // eslint-disable-next-line no-unused-vars
      for (const locale of statusfyOptions.locales) {
        const lang = locale.code;
        const calPath = path.join(
          this.options.generate.dir,
          "calendars",
          `scheduled.${locale.code}.ics`
        );

        const content = await createCalendar(statusfyOptions.siteConfig, lang);

        // Ensure no calendar file exists
        await fse.remove(calPath);
        await fse.ensureFile(calPath);

        await fse.writeFile(calPath, content);

        logger.success(`Generated /calendars/scheduled.${locale.code}.ics`);
      }
    }
  });
};
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
this.nuxt.hook("generate:done", async generator => {
    await copyPublicFiles(
      statusfyOptions.publicFilesPath,
      this.options.generate.dir
    );

    /* Sitemap */
    const sitemap = await createSitemap(statusfyOptions.siteConfig);
    const xmlPath = path.join(this.options.generate.dir, "sitemap.xml");

    // Ensure no sitemap file exists
    await fse.remove(xmlPath);
    await fse.ensureFile(xmlPath);

    await fse.writeFile(xmlPath, sitemap);

    logger.success("Generated /sitemap.xml");

    /* Feeds */
    if (
      statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.feeds
    ) {
      // eslint-disable-next-line no-unused-vars
      for (const locale of statusfyOptions.locales) {
        const feeds = await createFeeds(
          statusfyOptions.siteConfig,
          locale.code
github bazzite / statusfy / packages / @statusfy / core / client / modules / statusfy / index.js View on Github external
const rssPath = path.join(
          this.options.generate.dir,
          "feeds",
          `incidents.${locale.code}.xml`
        );
        const atomPath = path.join(
          this.options.generate.dir,
          "feeds",
          `incidents.${locale.code}.atom`
        );

        // Ensure no feed file exists
        await fse.remove(rssPath);
        await fse.ensureFile(rssPath);
        await fse.remove(atomPath);
        await fse.ensureFile(atomPath);

        await fse.writeFile(rssPath, feeds.rss());
        await fse.writeFile(atomPath, feeds.atom());

        logger.success(`Generated /feeds/incidents.${locale.code}.xml`);
        logger.success(`Generated /feeds/incidents.${locale.code}.atom`);
      }
    }

    /* Calendars */
    if (
      statusfyOptions.siteConfig.notifications &&
      statusfyOptions.siteConfig.notifications.icalendar
    ) {
      // eslint-disable-next-line no-unused-vars
github bazzite / statusfy / packages / @statusfy / core / lib / delete-incident.js View on Github external
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
              ? "This file was successfully deleted"
              : "These files were successfully deleted";

          logger.success(`${prefix}: \n${deletedFiles.join("\n")}`);