X-Git-Url: https://git.r.bdr.sh/rbdr/blog/blobdiff_plain/fac54389550aaab8bcb4ad1e6b0b1900fd8887d2..65d379f5db381423165e0da8cc788f85112873b8:/lib/blog.js diff --git a/lib/blog.js b/lib/blog.js index 8ae3e21..ff52554 100644 --- a/lib/blog.js +++ b/lib/blog.js @@ -3,7 +3,7 @@ const { access, mkdir, readdir, readFile, rm, writeFile } = require('fs/promises'); const { exec } = require('child_process'); const { ncp } = require('ncp'); -const { join } = require('path'); +const { resolve, join } = require('path'); const ParseGemini = require('gemini-to-html/parse'); const RenderGemini = require('gemini-to-html/render'); const { debuglog, promisify } = require('util'); @@ -126,6 +126,38 @@ module.exports = class Blog { internals.debuglog('Finished publishing'); } + /** + * Publishes the archive to a host using rsync. Currently assumes + * gemlog archive. + * + * @function publishArchive + * @memberof Blog + * @return {Promise} empty promise, returns no value + * @instance + */ + async publishArchive(host) { + + internals.debuglog(`Publishing archive to ${host}`); + try { + await internals.exec('which rsync'); + } + catch (err) { + console.error('Please install rsync to publish the archive.'); + } + + try { + const gemlogPath = resolve(join(__dirname, '../', '.gemlog')); + internals.debuglog(`Reading archive from ${gemlogPath}`); + await internals.exec(`rsync -r ${gemlogPath}/ ${host}`); + } + catch (err) { + console.error('Failed to publish archive'); + console.error(err.stderr); + } + + internals.debuglog('Finished publishing'); + } + // Parses Gemini for each page, copies assets and generates index. async generate() {