Skip to content

Commit 625313c

Browse files
committed
await the copy commands
1 parent 0c6ee8b commit 625313c

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

src/services/site-generator.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,19 @@ export class SiteGenerator {
110110
msg: `Creating image browser for ${item.collectionId}/${item.itemId}`,
111111
level: "info"
112112
});
113-
this.createImageBrowserPage({ item });
113+
await this.createImageBrowserPage({ item });
114114

115115
this.log({
116116
msg: `Creating media browser ${item.collectionId}/${item.itemId}`,
117117
level: "info"
118118
});
119-
this.createMediaBrowserPage({ item });
119+
await this.createMediaBrowserPage({ item });
120120

121121
this.log({
122122
msg: `Creating documents browser ${item.collectionId}/${item.itemId}`,
123123
level: "info"
124124
});
125-
this.createDocumentsBrowserPage({ item });
125+
await this.createDocumentsBrowserPage({ item });
126126

127127
this.log({
128128
msg: `Done generating ${item.collectionId}/${item.itemId}`,
@@ -304,7 +304,7 @@ export class SiteGenerator {
304304
fs.writeFileSync(file, html);
305305
}
306306

307-
createImageBrowserPage({ item }) {
307+
async createImageBrowserPage({ item }) {
308308
shelljs.mkdir("-p", `${item.path}/images/content`);
309309
for (let i = 0; i < item.images.length; i++) {
310310
const first = `${item.images[0].path.split("/").pop()}.html`;
@@ -327,8 +327,11 @@ export class SiteGenerator {
327327
last: i === item.images.length - 1 ? null : last
328328
};
329329
if (shelljs.test("-e", image.path)) {
330-
this.copyFile(image.path, `${item.path}/images/content`);
331-
this.copyFile(image.thumbnail, `${item.path}/images/content`);
330+
await this.copyFile(image.path, `${item.path}/images/content`);
331+
await this.copyFile(
332+
image.thumbnail,
333+
`${item.path}/images/content`
334+
);
332335

333336
const file = `${item.path}/images/${image.path
334337
.split("/")
@@ -340,12 +343,12 @@ export class SiteGenerator {
340343
}
341344
}
342345

343-
createMediaBrowserPage({ item }) {
346+
async createMediaBrowserPage({ item }) {
344347
shelljs.mkdir("-p", `${item.path}/media/content`);
345348
let content;
346349
for (let file of item.audio) {
347350
if (shelljs.test("-e", file.path)) {
348-
this.copyFile(file.path, `${item.path}/media/content`);
351+
await this.copyFile(file.path, `${item.path}/media/content`);
349352
}
350353
content = {
351354
title: item.title,
@@ -367,7 +370,7 @@ export class SiteGenerator {
367370
item: file
368371
};
369372
if (shelljs.test("-e", file.path)) {
370-
this.copyFile(file.path, `${item.path}/media/content`);
373+
await this.copyFile(file.path, `${item.path}/media/content`);
371374
}
372375
file = `${item.path}/media/${file.name}.html`;
373376
const template = this.getPath("video-browser.njk");
@@ -376,13 +379,16 @@ export class SiteGenerator {
376379
}
377380
}
378381

379-
createDocumentsBrowserPage({ item }) {
382+
async createDocumentsBrowserPage({ item }) {
380383
shelljs.mkdir("-p", `${item.path}/documents/content`);
381-
item.documents.forEach(document => {
384+
for (let document of item.documents) {
382385
if (shelljs.test("-e", document.path)) {
383-
this.copyFile(document.path, `${item.path}/documents/content`);
386+
await this.copyFile(
387+
document.path,
388+
`${item.path}/documents/content`
389+
);
384390
}
385-
});
391+
}
386392
}
387393

388394
async copyFile(source, target) {

0 commit comments

Comments
 (0)