fix regex filter
This commit is contained in:
		
							
								
								
									
										18
									
								
								dist/smartfile.fs.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										18
									
								
								dist/smartfile.fs.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										20
									
								
								test/test.js
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								test/test.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										18
									
								
								test/test.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								test/test.ts
									
									
									
									
									
								
							| @@ -40,6 +40,24 @@ describe("smartfile".yellow,function(){ | ||||
|                     }); | ||||
|             }); | ||||
|         }); | ||||
|         describe(".listFilesSync()",function(){ | ||||
|             it("should get the file type from a string",function(){ | ||||
|                 smartfile.fs.listFilesSync("./test/").should.containDeep([ "mytest.json"]); | ||||
|                 smartfile.fs.listFilesSync("./test/").should.not.containDeep([ "notExistentFile"]); | ||||
|                 smartfile.fs.listFilesSync("./test/",/mytest\.json/).should.containDeep([ "mytest.json"]); | ||||
|                 smartfile.fs.listFilesSync("./test/",/mytests.json/).should.not.containDeep([ "mytest.json"]); | ||||
|             }); | ||||
|         }); | ||||
|         describe(".listFiles()",function(){ | ||||
|             it("should get the file type from a string",function(done){ | ||||
|                 smartfile.fs.listFiles("./test/") | ||||
|                     .then(function(folderArrayArg){ | ||||
|                         folderArrayArg.should.containDeep([ "mytest.json"]); | ||||
|                         folderArrayArg.should.not.containDeep([ "notExistentFile"]); | ||||
|                         done(); | ||||
|                     }); | ||||
|             }); | ||||
|         }); | ||||
|         describe(".copy()".yellow,function(){ | ||||
|             it("should copy a directory",function(){ | ||||
|                 smartfile.fs.copy("./test/testfolder/","./test/temp/") | ||||
|   | ||||
| @@ -182,7 +182,7 @@ export let listFolders = function(pathArg:string,regexFilter?:RegExp){ | ||||
|     }); | ||||
|     if(regexFilter){ | ||||
|         folderArray = folderArray.filter((fileItem) => { | ||||
|             regexFilter.test(fileItem); | ||||
|             return regexFilter.test(fileItem); | ||||
|         }); | ||||
|     } | ||||
|     done.resolve(folderArray); | ||||
| @@ -199,7 +199,7 @@ export let listFoldersSync = function(pathArg:string,regexFilter?:RegExp):string | ||||
|     }); | ||||
|     if(regexFilter){ | ||||
|         folderArray = folderArray.filter((fileItem) => { | ||||
|             regexFilter.test(fileItem); | ||||
|             return regexFilter.test(fileItem); | ||||
|         }); | ||||
|     }; | ||||
|     return folderArray; | ||||
| @@ -217,11 +217,11 @@ export let listFiles = function(pathArg:string, regexFilter?:RegExp){ | ||||
|     }); | ||||
|     if(regexFilter){ | ||||
|         fileArray = fileArray.filter((fileItem) => { | ||||
|             regexFilter.test(fileItem); | ||||
|             return regexFilter.test(fileItem); | ||||
|         }); | ||||
|     }; | ||||
|     done.resolve(fileArray); | ||||
|     return done.promise(); | ||||
|     return done.promise; | ||||
| }; | ||||
|  | ||||
| /** | ||||
| @@ -234,7 +234,7 @@ export let listFilesSync = function(pathArg:string, regexFilter?:RegExp):string[ | ||||
|     }); | ||||
|     if(regexFilter){ | ||||
|         fileArray = fileArray.filter((fileItem) => { | ||||
|             regexFilter.test(fileItem); | ||||
|             return regexFilter.test(fileItem); | ||||
|         }); | ||||
|     }; | ||||
|     return fileArray; | ||||
| @@ -249,11 +249,11 @@ export let listAllItems = function(pathArg:string, regexFilter?:RegExp){ | ||||
|     let allItmesArray = plugins.fs.readdirSync(pathArg); | ||||
|     if(regexFilter){ | ||||
|         allItmesArray = allItmesArray.filter((fileItem) => { | ||||
|             regexFilter.test(fileItem); | ||||
|             return regexFilter.test(fileItem); | ||||
|         }); | ||||
|     }; | ||||
|     done.resolve(allItmesArray); | ||||
|     return done.promise(); | ||||
|     return done.promise; | ||||
| }; | ||||
|  | ||||
| /** | ||||
| @@ -266,7 +266,7 @@ export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):stri | ||||
|     }); | ||||
|     if(regexFilter){ | ||||
|         allItmesArray = allItmesArray.filter((fileItem) => { | ||||
|             regexFilter.test(fileItem); | ||||
|             return regexFilter.test(fileItem); | ||||
|         }); | ||||
|     }; | ||||
|     return allItmesArray; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user