generate-examples-index-webpack-plugin
Version:
Generate an examples index page from your examples folder
22 lines (17 loc) • 438 B
JavaScript
const fs = require('fs');
const stripExtension = require('./stripExtension');
/**
* Given a html file, return the associated file without extension
*
* @param htmlFile
*/
function getAssociatedFile(htmlFile, extensions) {
const noExt = stripExtension(htmlFile);
for (const ext of extensions) {
if (fs.existsSync(`${noExt}.${ext}`)) {
return noExt;
}
}
return undefined;
}
module.exports = getAssociatedFile;