X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/65d379f5db381423165e0da8cc788f85112873b8..9eac24780006862171b85858b40db0f29f494e76:/lib/archivers/gemlog.js?ds=sidebyside diff --git a/lib/archivers/gemlog.js b/lib/archivers/gemlog.js index 50bb334..3e08be4 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) { @@ -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 }); } };