Comparing version 1.1.2 to 1.1.3
@@ -5,3 +5,3 @@ // emptyDir,rmDir,getAllFiles,request,session,token | ||
declare function rmDir(dirPath:string):boolean; | ||
declare function getAllFiles(dirPath:string, recursion?:boolean):string[]; | ||
declare function getAllFiles(dirPath:string, ext?:string ,recursion?:boolean):string[]; | ||
declare function request(url:string,options:Object):Promise<Object>; | ||
@@ -8,0 +8,0 @@ declare function session(options:Object):(ctx:any,next:Function)=>Promise<any>; |
const fs = require('fs'); | ||
const path = require('path'); | ||
const { getType } = require('yu-util'); | ||
exports.getAllFiles = (dirPath, recursion=true) => { | ||
exports.getAllFiles = (dirPath, ext, recursion=true) => { | ||
getType(ext)==='Boolean' && (recursion = ext); | ||
ext = getType(ext)==='String' ? ext : '*'; | ||
let arr = []; | ||
@@ -19,3 +22,5 @@ const bool = fs.existsSync(dirPath); //判断目录是否存在 | ||
}else{ | ||
arr.push(child); | ||
let file = path.parse(dirent.name); | ||
let bool = (ext==='*' || file.ext==='.'+ext) ? true :false; | ||
bool && arr.push(child); | ||
} | ||
@@ -22,0 +27,0 @@ }); |
{ | ||
"name": "yu-node", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"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
7889
164