From 8935d1b4f53c5590aeaad7229f09b168cd39b99a Mon Sep 17 00:00:00 2001 From: James Perez Date: Tue, 5 Nov 2024 19:00:09 -0800 Subject: [PATCH] inline the embedFiles function --- lib/index.js | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/index.js b/lib/index.js index c424dede..df1cb287 100644 --- a/lib/index.js +++ b/lib/index.js @@ -362,19 +362,6 @@ export class Baker extends EventEmitter { }, preppedData); } - embedFiles(path) { - return new Promise((resolve, reject) => { - readdir(path, (err, files) => { - //handling error - if (err) { - reject('Unable to scan directory: ' + err); - } - - resolve(files); - }); - }); - } - /** * Generates fallback images for web-component embeds. * @param {string} baseUrl The local server's base URL @@ -384,11 +371,21 @@ export class Baker extends EventEmitter { async buildEmbedFallbacks(baseUrl) { const distDir = this.output.split('/').slice(0, -1).join('/'); const embedFilePattern = path.join(distDir, '_dist', 'embeds'); + /** * An array of file paths representing embed files. * @type {string[]} */ - const embedFiles = await this.embedFiles(embedFilePattern); + const embedFiles = await (new Promise((resolve, reject) => { + readdir(embedFilePattern, (err, files) => { + //handling error + if (err) { + reject('Unable to scan directory: ' + err); + } + + resolve(files); + }); + })); if (!embedFiles.length) return;