X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/65d379f5db381423165e0da8cc788f85112873b8..3563ec23663e856fbaaa747bc174019ea4a3bcd4:/lib/archivers/gemlog.js?ds=sidebyside diff --git a/lib/archivers/gemlog.js b/lib/archivers/gemlog.js index 50bb334..3443c66 100644 --- a/lib/archivers/gemlog.js +++ b/lib/archivers/gemlog.js @@ -1,14 +1,13 @@ -const { mkdir, readdir, rm, writeFile } = require('fs/promises'); -const { debuglog, promisify } = require('util'); -const { ncp } = require('ncp'); +const { cp, mkdir, readdir, writeFile } = require('fs/promises'); +const { debuglog } = require('util'); const { resolve, join } = require('path'); +const { rmIfExists } = require('../utils'); const internals = { kArchiveName: resolve(join(__dirname, '../..', '.gemlog')), kIndexName: 'index.gmi', kGeminiRe: /\.gmi$/i, - ncp: promisify(ncp), debuglog: debuglog('blog'), buildUrl(id, slug) { @@ -43,9 +42,9 @@ module.exports = async function(archiveDirectory) { internals.debuglog(`Read ${posts.length} posts`); const index = [ - '# Unlimited Pizza Gemlog Archive', '', - '=> https://blog.unlimited.pizza/feed.xml 📰 RSS Feed', - '=> https://blog.unlimited.pizza/index.txt 📑 http text version (latest 3 posts)', + '# Ruben\'s Gemlog Archive', '', + '=> https://r.bdr.sh/gemlog/feed.xml 📰 RSS Feed', + '=> https://r.bdr.sh/gemlog/index.txt 📑 http text version (latest 3 posts)', '', ...posts.map((post) => internals.buildLink(post.id, post.slug)), '', '=> ../ 🪴 Back to main page' @@ -53,7 +52,7 @@ module.exports = async function(archiveDirectory) { try { internals.debuglog('Removing index'); - await rm(internals.kArchiveName, { recursive: true }); + await rmIfExists(internals.kArchiveName); } finally { internals.debuglog('Creating index'); @@ -62,6 +61,6 @@ module.exports = async function(archiveDirectory) { await writeFile(indexFile, index); internals.debuglog('Copying posts to archive'); - await internals.ncp(archiveDirectory, internals.kArchiveName); + await cp(archiveDirectory, internals.kArchiveName, { recursive: true }); } };