]> git.r.bdr.sh - rbdr/blog/blobdiff - lib/generators/static.js
Allow sync up and down
[rbdr/blog] / lib / generators / static.js
diff --git a/lib/generators/static.js b/lib/generators/static.js
deleted file mode 100644 (file)
index 45f5a04..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-import { access, cp, readdir } from 'fs/promises';
-import { constants } from 'fs';
-import { join } from 'path';
-import { debuglog } from 'util';
-import { kFileNotFoundError } from '../constants.js';
-
-const internals = {
-  debuglog: debuglog('blog'),
-  kAssetsDirectoryName: 'assets'
-};
-
-/**
- * Generates the static assets required for the blog
- *
- * @name StaticGenerator
- * @param {string} source the source directory
- * @param {string} target the target directory
- * @param {Array.<Blog.tPost>} posts the list of posts
- */
-export default async function StaticGenerator(source, target, _) {
-
-  try {
-    await access(source, constants.R_OK);
-
-    const entries = await readdir(source, { withFileTypes: true });
-    for (const entry of entries) {
-      const sourceAsset = join(source, entry.name);
-      const targetAsset = join(target, entry.name);
-
-      internals.debuglog(`Copying ${sourceAsset} to ${targetAsset}`);
-
-      if (entry.isDirectory()) {
-        await cp(sourceAsset, targetAsset, { recursive: true });
-      }
-      else {
-        await cp(sourceAsset, targetAsset);
-      }
-    }
-  }
-  catch (error) {
-    if (error.code === kFileNotFoundError) {
-      internals.debuglog(`No static directory found in ${source}`);
-      return;
-    }
-
-    throw error;
-  }
-}