Skip to content
Draft
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
53 changes: 46 additions & 7 deletions convert/convertBooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,43 @@ export async function convertBooks(
const frozen = freeze(pk);
freezer.set(context.docSet, frozen[context.docSet]);
//start catalog generation process
catalogEntries.push(pk.gqlQuery(queries.catalogQuery({ cv: true })));
catalogEntries.push(
pk.gqlQuery(queries.catalogQuery({ cv: true })).then((j) => {
if (j.data.nDocSets > 0) {
return j;
} else {
if (verbose) {
console.log(` -- Empty DocSet: ${context.docSet}`);
}
// return empty version of appropriate docSet,
// as the query failed due to lack of documents.
return {
data: {
nDocSets: 1,
nDocuments: 0,
docSets: [
{
id: context.docSet,
tagsKv: [],
selectors: [
{
key: 'lang',
value: context.lang
},
{
key: 'abbr',
value: context.bcId
}
],
hasMapping: false,
documents: []
}
]
}
};
}
})
);

//check if folder exists for collection
const collPath = path.join('static', 'collections', context.bcId);
Expand Down Expand Up @@ -263,12 +299,15 @@ export async function convertBooks(
//write frozen archives

//push files to be written to files array
freezer.forEach((value, key) =>
files.push({
path: path.join('static', 'collections', key + '.pkf'),
content: value
})
);
freezer.forEach((value, key) => {
// don't write pkf if there is nothing to write
if (value) {
files.push({
path: path.join('static', 'collections', key + '.pkf'),
content: value
});
}
});

//write index file
writeFileSync(
Expand Down