Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: renderDatasetSite #9

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading