aboutsummaryrefslogtreecommitdiff
path: root/lib/generators/static.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/generators/static.js')
-rw-r--r--lib/generators/static.js48
1 files changed, 0 insertions, 48 deletions
diff --git a/lib/generators/static.js b/lib/generators/static.js
deleted file mode 100644
index 45f5a04..0000000
--- a/lib/generators/static.js
+++ /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;
- }
-}