Skip to content

Commit

Permalink
fix: renderDatasetSite
Browse files Browse the repository at this point in the history
  • Loading branch information
nickevansuk committed Oct 5, 2023
1 parent eacd582 commit 96721db
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Mustache = require('mustache');
const fs = require('fs');
const fsSync = require('fs');
const fs = require('fs').promises;
const path = require('path');
const pjson = require('../package.json');
const extract = require('extract-zip')
Expand All @@ -21,7 +22,7 @@ async function getDatasetSiteTemplate(singleFileMode) {

function getDatasetSiteTemplateSync(singleFileMode) {
// Get pre-rendered template from ./dist/
return fs.readFileSync(getDistFullPath(getDatasetSiteTemplateFilename(singleFileMode)), { encoding:'utf8' });
return fsSync.readFileSync(getDistFullPath(getDatasetSiteTemplateFilename(singleFileMode)), { encoding:'utf8' });
}

async function renderDatasetSite(jsonld, staticAssetsPathUrl) {
Expand Down Expand Up @@ -72,7 +73,7 @@ function renderDatasetSiteData(jsonld, staticAssetsPathUrl) {
function copyFileFromDistToDirectorySync(destinationRelativeDirectoryPath, filename) {
const sourcePath = getDistFullPath(filename);
const destinationPath = path.join(process.cwd(), destinationRelativeDirectoryPath, filename);
fs.copyFileSync(sourcePath, destinationPath);
fsSync.copyFileSync(sourcePath, destinationPath);
}

async function unzipFileFromDistToDirectory(filename, destinationRelativeDirectoryPath) {
Expand All @@ -88,21 +89,21 @@ function copyTemplateSync(destinationRelativePath, singleFileMode) {

function writeTemplatesToDirectorySync(destinationRelativeDirectoryPath) {
// Create output directory if it does not already exist
fs.mkdirSync(path.join(process.cwd(), destinationRelativeDirectoryPath) , { recursive: true });
fsSync.mkdirSync(path.join(process.cwd(), destinationRelativeDirectoryPath) , { recursive: true });
copyTemplateSync(destinationRelativeDirectoryPath, true);
copyTemplateSync(destinationRelativeDirectoryPath, false);
}

function writeAssetsArchiveToDirectorySync(destinationRelativeDirectoryPath) {
// Create output directory if it does not already exist
fs.mkdirSync(path.join(process.cwd(), destinationRelativeDirectoryPath) , { recursive: true });
fsSync.mkdirSync(path.join(process.cwd(), destinationRelativeDirectoryPath) , { recursive: true });

copyFileFromDistToDirectorySync(destinationRelativeDirectoryPath, CSP_ASSET_ARCHIVE_FILENAME);
}

async function unzipAssetsArchiveToDirectory(destinationRelativeDirectoryPath) {
// Create output directory if it does not already exist
fs.mkdirSync(path.join(process.cwd(), destinationRelativeDirectoryPath) , { recursive: true });
fsSync.mkdirSync(path.join(process.cwd(), destinationRelativeDirectoryPath) , { recursive: true });

await unzipFileFromDistToDirectory(CSP_ASSET_ARCHIVE_FILENAME, destinationRelativeDirectoryPath);
}
Expand Down

0 comments on commit 96721db

Please sign in to comment.