UNPKG

generate-examples-index-webpack-plugin

Version:
22 lines (17 loc) 438 B
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;