const fs = require('fs');
const path = require('path');
let pathSupplied = './';
let extFilter = 'js';
let extension = (element) => {
let extName = path.extname(element);
return extName === '.' + extFilter;
};
let walk = function (dir) {
fs.readdir(dir, function (err, list) {
list.forEach((item) => {
let itemPath = path.join(dir, item);
fs.stat(itemPath, (e, stats) => {
if (stats.isDirectory()) {
walk(itemPath);
} else {
if(extension(itemPath)){
console.log(itemPath)
}
}
});
});
})
}
walk(pathSupplied)
const fs = require('fs');
const path = require('path');
let pathSupplied = './';
let extFilter = 'js';
let extension = (element) => {
let extName = path.extname(element);
return extName === '.' + extFilter;
};
let walk = function (dir) {
const result = [];
fs.readdir(dir, function (err, list) {
list.forEach((item) => {
let itemPath = path.join(dir, item);
fs.stat(itemPath, (e, stats) => {
if (stats.isDirectory()) {
walk(itemPath);
} else {
if(extension(itemPath)){
console.log(itemPath)
result.push(itemPath);
}
}
});
});
});
return result;
}
walk(pathSupplied);
walkAsync = (dir)=>{
return new Promise((resolve)=>{
resolve(walk(dir))
});
}