diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-08 20:44:49 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-05-08 20:44:49 +0200 |
| commit | 65d379f5db381423165e0da8cc788f85112873b8 (patch) | |
| tree | 10b52164cc2ae5f863549305ecec97e3ab96cd80 /lib/blog.js | |
| parent | fac54389550aaab8bcb4ad1e6b0b1900fd8887d2 (diff) | |
Add archive publishing
Diffstat (limited to 'lib/blog.js')
| -rw-r--r-- | lib/blog.js | 34 |
1 files changed, 33 insertions, 1 deletions
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<undefined>} 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() { |