-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpowerpoint.js
38 lines (33 loc) · 1.08 KB
/
powerpoint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const PptxGenJS = require("pptxgenjs");
const fs = require("fs/promises");
const util = require("util");
const exec = util.promisify(require('child_process').exec);
class PowerPoint {
constructor() {
this.pres = new PptxGenJS();
this.slides = [];
this.ckaTemplate = require("./master-slides/cka")(this.pres);
}
async addSlides() {
let slidesNames = (await fs.readdir("./slides"));
for (let slideName of slidesNames) {
if (slideName !== "media")
this.slides.push(await require(`./slides/${slideName}`)(this));
}
}
async savePresentation() {
await this.pres.writeFile({fileName: `Message Board (initial).pptx`});
await this.combinePresentations();
}
//add custom made slides to the presentation
async combinePresentations() {
try {
await fs.stat('./Additional Slides.pptx')
await exec('python ./MergePPT.py')
} catch {
await fs.rename("./Message Board (initial).pptx", "./Message Board.pptx")
console.log("'Additional Slides.pptx' does not exist, no merge needed.")
}
}
}
module.exports = PowerPoint;