fix: explicitly clear generated rss folder to prevent file write appending

This commit is contained in:
William Grant 2022-07-29 11:53:57 +10:00
parent 9ae02052ea
commit 11f73d8011
3 changed files with 20 additions and 0 deletions

View File

@ -33,6 +33,7 @@
"react-scripts": "^4.0.2",
"react-use": "^17.1.1",
"redux": "^4.0.5",
"rimraf": "^3.0.2",
"sharp": "^0.30.1",
"uuid": "^8.3.2",
"xss": "^1.0.9"
@ -49,6 +50,7 @@
"@types/react": "^17.0.2",
"@types/react-redux": "^7.1.9",
"@types/redux": "^3.6.0",
"@types/rimraf": "^3.0.2",
"autoprefixer": "^10.2.4",
"contentful-cli": "^1.8.17",
"cssnano": "^4.1.11",

View File

@ -3,6 +3,7 @@ import { mkdirSync, writeFileSync } from 'fs';
import { Feed } from 'feed';
import { IPost } from '@/types/cms';
import { METADATA } from '@/constants';
import rimraf from 'rimraf';
const baseUrl = METADATA.HOST_URL;
const date = new Date();
@ -42,6 +43,7 @@ export default function generateRSSFeed(posts: IPost[]) {
});
});
rimraf.sync(`./public/rss`);
mkdirSync(`./public/rss`, { recursive: true });
writeFileSync(`./public/rss/feed.xml`, feed.rss2(), {
encoding: 'utf-8',

View File

@ -2018,6 +2018,14 @@
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==
"@types/glob@*":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"
"@types/glob@^7.1.1":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
@ -2160,6 +2168,14 @@
dependencies:
"@types/node" "*"
"@types/rimraf@^3.0.2":
version "3.0.2"
resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-3.0.2.tgz#a63d175b331748e5220ad48c901d7bbf1f44eef8"
integrity sha512-F3OznnSLAUxFrCEu/L5PY8+ny8DtcFRjx7fZZ9bycvXRi3KPTRS9HOitGZwvPg0juRhXFWIeKX58cnX5YqLohQ==
dependencies:
"@types/glob" "*"
"@types/node" "*"
"@types/source-list-map@*":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@types/source-list-map/-/source-list-map-0.1.2.tgz#0078836063ffaf17412349bba364087e0ac02ec9"