Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
38f10e0d04 | |||
2e2b8351f8 | |||
8c386ee91c |
18
dist/smartfile.fs.js
vendored
18
dist/smartfile.fs.js
vendored
File diff suppressed because one or more lines are too long
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartfile",
|
"name": "smartfile",
|
||||||
"version": "4.0.7",
|
"version": "4.0.8",
|
||||||
"description": "offers smart ways to work with files in nodejs",
|
"description": "offers smart ways to work with files in nodejs",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
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(){
|
describe(".copy()".yellow,function(){
|
||||||
it("should copy a directory",function(){
|
it("should copy a directory",function(){
|
||||||
smartfile.fs.copy("./test/testfolder/","./test/temp/")
|
smartfile.fs.copy("./test/testfolder/","./test/temp/")
|
||||||
|
@ -182,7 +182,7 @@ export let listFolders = function(pathArg:string,regexFilter?:RegExp){
|
|||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
folderArray = folderArray.filter((fileItem) => {
|
folderArray = folderArray.filter((fileItem) => {
|
||||||
regexFilter.test(fileItem);
|
return regexFilter.test(fileItem);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
done.resolve(folderArray);
|
done.resolve(folderArray);
|
||||||
@ -199,7 +199,7 @@ export let listFoldersSync = function(pathArg:string,regexFilter?:RegExp):string
|
|||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
folderArray = folderArray.filter((fileItem) => {
|
folderArray = folderArray.filter((fileItem) => {
|
||||||
regexFilter.test(fileItem);
|
return regexFilter.test(fileItem);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return folderArray;
|
return folderArray;
|
||||||
@ -217,11 +217,11 @@ export let listFiles = function(pathArg:string, regexFilter?:RegExp){
|
|||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
fileArray = fileArray.filter((fileItem) => {
|
fileArray = fileArray.filter((fileItem) => {
|
||||||
regexFilter.test(fileItem);
|
return regexFilter.test(fileItem);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
done.resolve(fileArray);
|
done.resolve(fileArray);
|
||||||
return done.promise();
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -234,7 +234,7 @@ export let listFilesSync = function(pathArg:string, regexFilter?:RegExp):string[
|
|||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
fileArray = fileArray.filter((fileItem) => {
|
fileArray = fileArray.filter((fileItem) => {
|
||||||
regexFilter.test(fileItem);
|
return regexFilter.test(fileItem);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return fileArray;
|
return fileArray;
|
||||||
@ -249,11 +249,11 @@ export let listAllItems = function(pathArg:string, regexFilter?:RegExp){
|
|||||||
let allItmesArray = plugins.fs.readdirSync(pathArg);
|
let allItmesArray = plugins.fs.readdirSync(pathArg);
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
allItmesArray = allItmesArray.filter((fileItem) => {
|
allItmesArray = allItmesArray.filter((fileItem) => {
|
||||||
regexFilter.test(fileItem);
|
return regexFilter.test(fileItem);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
done.resolve(allItmesArray);
|
done.resolve(allItmesArray);
|
||||||
return done.promise();
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -266,7 +266,7 @@ export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):stri
|
|||||||
});
|
});
|
||||||
if(regexFilter){
|
if(regexFilter){
|
||||||
allItmesArray = allItmesArray.filter((fileItem) => {
|
allItmesArray = allItmesArray.filter((fileItem) => {
|
||||||
regexFilter.test(fileItem);
|
return regexFilter.test(fileItem);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return allItmesArray;
|
return allItmesArray;
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"globalDependencies": {
|
|
||||||
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
|
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
|
||||||
"node": "registry:dt/node",
|
|
||||||
"should": "registry:dt/should"
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user