UNPKG

generate-examples-index-webpack-plugin

Version:
17 lines (14 loc) 374 B
const fs = require('fs'); /** * Given an existing html file, return its title, if any * * @param file route of the file * @returns title or empty string */ function getHtmlTitle(file) { const regExp = /<title>(.*)<\/title>/; const html = fs.readFileSync(file); const match = regExp.exec(html); return match && match[1] || ''; } module.exports = getHtmlTitle;