You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
667 B
26 lines
667 B
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
|
|
module.exports = {
|
|
readFileDeep(dir) {
|
|
const routes = {
|
|
dir: [],
|
|
file: []
|
|
};
|
|
const routeFunc = (dirname) => {
|
|
const files = fs.readdirSync(path.resolve(dirname));
|
|
files.forEach(file => {
|
|
if (fs.statSync(path.resolve(dirname, file)).isDirectory()) {
|
|
routes.dir.push(path.resolve(dirname, file));
|
|
routeFunc(path.resolve(dirname, file))
|
|
}
|
|
if (fs.statSync(path.resolve(dirname, file)).isFile()) {
|
|
routes.file.push(path.resolve(dirname, file));
|
|
}
|
|
})
|
|
return routes
|
|
}
|
|
return routeFunc(dir);
|
|
}
|
|
}
|