Skip to content

Commit

Permalink
inline the embedFiles function
Browse files Browse the repository at this point in the history
  • Loading branch information
jperezlatimes committed Nov 6, 2024
1 parent 6c5ffde commit 8935d1b
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;

Expand Down

0 comments on commit 8935d1b

Please sign in to comment.