Closed karneaud closed 1 month ago
When compiling pug files in folder and there are empty folders I get the subject error:-
HTML compilation Error compiling pug file Error: EISDIR : is a directory
Which causes the compilation to terminate. Had to hack a workaround by changing this
async compilePug() { this.debugLog('HTML compilation'); try { await this.compile({ filePaths: this.config.htmlFiles, extensionSkip: '.html', type: 'Pug', newFileExt: '.html', dist: this.config.distDir, renderFn: (filePath) => { return pug.renderFile(filePath, { pretty: false, cache: false, compileDebug: this.config.debug, sitemap: this.config.htmlFiles.map((file) => path.basename(path.resolve(file).replace(/\.pug$/, '.html')), ), readFileSync, }); }, }); } catch (error) { this.errLog('Error while compiling pug files'); this.errThrow(error); } }
with this
async compilePug() { this.debugLog('HTML compilation'); try { await this.compile({ filePaths: this.config.htmlFiles, extensionSkip: '.html', type: 'Pug', newFileExt: '.html', dist: this.config.distDir, renderFn: (filePath) => { // Check if filePath is a file and not a directory const fullPath = path.resolve(filePath); // Only render if it's a file if (fs.lstatSync(fullPath).isFile()) { return pug.renderFile(fullPath, { pretty: false, cache: false, compileDebug: this.config.debug, sitemap: this.config.htmlFiles .filter((file) => fs.lstatSync(file).isFile()) // Filter directories from sitemap too .map((file) => path.basename(file).replace(/\.pug$/, '.html')), readFileSync, }); } else { this.debugLog(`Skipping: ${fullPath} is a directory`); } }, }); } catch (error) { this.errLog('Error while compiling pug files'); this.errThrow(error); } }
@karneaud fixed, thanks for pointing out ❤️
When compiling pug files in folder and there are empty folders I get the subject error:-
Which causes the compilation to terminate. Had to hack a workaround by changing this
with this