lix-website/themes/lix/assets/bootstrap/node_modules/fs-readdir-recursive/index.js
2024-04-26 22:49:34 -06:00

30 lines
611 B
JavaScript

var fs = require('fs')
var path = require('path')
module.exports = read
function read(root, filter, files, prefix) {
prefix = prefix || ''
files = files || []
filter = filter || noDotFiles
var dir = path.join(root, prefix)
if (!fs.existsSync(dir)) return files
if (fs.statSync(dir).isDirectory())
fs.readdirSync(dir)
.filter(function (name, index) {
return filter(name, index, dir)
})
.forEach(function (name) {
read(root, filter, files, path.join(prefix, name))
})
else
files.push(prefix)
return files
}
function noDotFiles(x) {
return x[0] !== '.'
}