lix-website/themes/lix/assets/bootstrap/node_modules/fs-readdir-recursive/index.js

30 lines
611 B
JavaScript
Raw Normal View History

2024-04-27 03:39:10 +00:00
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] !== '.'
}