X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/65d379f5db381423165e0da8cc788f85112873b8..467390bc032585f28da6203f891764f4a66c33b7:/lib/archivers/gemlog.js?ds=inline 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 }); } };