/usr/lib/nodejs/fs-readdir-recursive/index.js is in node-fs-readdir-recursive 1.0.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 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(filter)
.forEach(function (name) {
read(root, filter, files, path.join(prefix, name))
})
else
files.push(prefix)
return files
}
function noDotFiles(x) {
return x[0] !== '.'
}
|