Created
January 8, 2019 19:49
-
-
Save townivan/00d12270c14d269512d33845e0bc274b to your computer and use it in GitHub Desktop.
Read all of the .html files in a folder without using a library like glob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const targetPath = './src/pages/' | |
// *.html files | |
let fileNamesArray = fs.readdirSync(targetPath).filter( (file) => { | |
return file.includes('.html') | |
}) | |
// 'all-comps.html', 'c090.html', 'c100.html', 'c101.html', 'c102.html', 'index.html' ] | |
// c*.html files | |
let fileNamesArray = fs.readdirSync(targetPath).filter( (file) => { | |
return file.includes('.html') && file.substring(0,1) == 'c' // c*.html files | |
}) | |
// [ 'c090.html', 'c100.html', 'c101.html', 'c102.html' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment