Comparing version 1.0.6 to 1.0.7
const fs = require('fs'); | ||
const path = require('path'); | ||
exports.getAllFiles = dirPath => { | ||
exports.getAllFiles = (dirPath, recursion=true) => { | ||
const bool = fs.existsSync(dirPath); //判断目录是否存在 | ||
@@ -9,16 +9,18 @@ if(!bool) return; | ||
let arr = []; | ||
fn(dirPath); | ||
function fn(dirPath){ | ||
(function fn(dirPath){ | ||
const dirents = fs.readdirSync(dirPath,{ withFileTypes:true }); | ||
dirents.forEach((dirent,i)=>{ | ||
dirents.forEach(dirent=>{ | ||
let child = path.join(dirPath,dirent.name); | ||
if(dirent.isDirectory()){ | ||
fn(child); | ||
recursion && fn(child); | ||
}else{ | ||
arr.push(path.resolve(dirPath,'../',child)); | ||
arr.push(path.resolve(child)); | ||
} | ||
}); | ||
} | ||
})(dirPath); | ||
return arr; | ||
} |
{ | ||
"name": "yu-node", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "仅用于node.js", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3085
52