now has fileTree function

This commit is contained in:
Philipp Kunz 2016-07-01 01:37:48 +02:00
parent 38f10e0d04
commit 23188dfe3f
10 changed files with 70 additions and 18 deletions

View File

@ -106,3 +106,4 @@ export declare let listAllItems: (pathArg: string, regexFilter?: RegExp) => any;
* @returns an array with the folder names as strings * @returns an array with the folder names as strings
*/ */
export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[]; export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
export declare let listFileTree: (dirPath: string, miniMatchFilter: string) => any;

17
dist/smartfile.fs.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
import "typings-global"; import "typings-global";
import plugins = require("./smartfile.plugins");
/** /**
* allows you to create a gulp stream * allows you to create a gulp stream
* from String, from an Array of Strings, from Vinyl File, from an Array of VinylFiles * from String, from an Array of Strings, from Vinyl File, from an Array of VinylFiles
@ -7,7 +6,7 @@ import plugins = require("./smartfile.plugins");
* @returns stream.Readable * @returns stream.Readable
* @TODO: make it async; * @TODO: make it async;
*/ */
export declare let toGulpStream: (fileArg: string | string[] | plugins.vinyl | plugins.vinyl[], baseArg?: string) => any; export declare let toGulpStream: (fileArg: any, baseArg?: string) => any;
/** /**
* converts file to Object * converts file to Object
* @param fileStringArg * @param fileStringArg
@ -24,7 +23,7 @@ export declare let toVinylFileSync: (fileArg: string, optionsArg?: {
filename?: string; filename?: string;
base?: string; base?: string;
relPath?: string; relPath?: string;
}) => plugins.vinyl; }) => any;
/** /**
* takes a string array and some options and returns a vinylfile array * takes a string array and some options and returns a vinylfile array
* @param arrayArg * @param arrayArg
@ -38,12 +37,12 @@ export declare let toVinylArraySync: (arrayArg: string[], optionsArg?: {
/** /**
* takes a vinylFile object and converts it to String * takes a vinylFile object and converts it to String
*/ */
export declare let toStringSync: (fileArg: plugins.vinyl) => string; export declare let toStringSync: (fileArg: any) => any;
/** /**
* writes string or vinyl file to disk. * writes string or vinyl file to disk.
* @param fileArg * @param fileArg
* @param fileNameArg * @param fileNameArg
* @param fileBaseArg * @param fileBaseArg
*/ */
export declare let toFs: (fileContentArg: string | plugins.vinyl, filePathArg: any) => any; export declare let toFs: (fileContentArg: any, filePathArg: any) => any;
export declare let toFsSync: (fileArg: any, filePathArg: string) => void; export declare let toFsSync: (fileArg: any, filePathArg: string) => void;

View File

@ -1,13 +1,14 @@
import "typings-global"; import "typings-global";
export declare let beautylog: any; export import beautylog = require("beautylog");
export declare let fs: any; export declare let fs: any;
export declare let gulp: any; export declare let gulp: any;
export declare let glob: any;
export declare let g: { export declare let g: {
remoteSrc: any; remoteSrc: any;
}; };
export import path = require("path"); export declare let path: any;
export declare let q: any; export declare let q: any;
export import vinyl = require("vinyl"); export declare let vinyl: any;
export declare let vinylFile: any; export declare let vinylFile: any;
export declare let yaml: any; export declare let yaml: any;
export declare let request: any; export declare let request: any;

View File

@ -3,6 +3,7 @@ require("typings-global");
exports.beautylog = require("beautylog"); exports.beautylog = require("beautylog");
exports.fs = require("fs-extra"); exports.fs = require("fs-extra");
exports.gulp = require("gulp"); exports.gulp = require("gulp");
exports.glob = require("glob");
exports.g = { exports.g = {
remoteSrc: require("gulp-remote-src") remoteSrc: require("gulp-remote-src")
}; };
@ -14,4 +15,4 @@ exports.yaml = require("js-yaml");
exports.request = require("request"); exports.request = require("request");
exports.requireReload = require("require-reload"); exports.requireReload = require("require-reload");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDYixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3pCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7Q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Iiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcbmV4cG9ydCBsZXQgZnMgPSByZXF1aXJlKFwiZnMtZXh0cmFcIik7XG5leHBvcnQgbGV0IGd1bHAgPSByZXF1aXJlKFwiZ3VscFwiKTtcbmV4cG9ydCBsZXQgZ2xvYiA9IHJlcXVpcmUoXCJnbG9iXCIpO1xuZXhwb3J0IGxldCBnID0ge1xuICAgIHJlbW90ZVNyYzogcmVxdWlyZShcImd1bHAtcmVtb3RlLXNyY1wiKVxufTtcbmV4cG9ydCBsZXQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuZXhwb3J0IGxldCBxID0gcmVxdWlyZShcInFcIik7XG5leHBvcnQgbGV0IHZpbnlsID0gcmVxdWlyZShcInZpbnlsXCIpO1xuZXhwb3J0IGxldCB2aW55bEZpbGUgPSByZXF1aXJlKFwidmlueWwtZmlsZVwiKTtcbmV4cG9ydCBsZXQgeWFtbCA9IHJlcXVpcmUoXCJqcy15YW1sXCIpO1xuZXhwb3J0IGxldCByZXF1ZXN0ID0gcmVxdWlyZShcInJlcXVlc3RcIik7XG5leHBvcnQgbGV0IHJlcXVpcmVSZWxvYWQgPSByZXF1aXJlKFwicmVxdWlyZS1yZWxvYWRcIik7XG4iXX0=

View File

@ -26,15 +26,18 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartfile", "homepage": "https://gitlab.com/pushrocks/smartfile",
"dependencies": { "dependencies": {
"@types/glob": "^5.0.22-alpha",
"@types/gulp": "^3.8.22-alpha",
"beautylog": "^5.0.12", "beautylog": "^5.0.12",
"fs-extra": "^0.30.0", "fs-extra": "^0.30.0",
"glob": "^7.0.5",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-remote-src": "^0.4.1", "gulp-remote-src": "^0.4.1",
"js-yaml": "^3.6.1", "js-yaml": "^3.6.1",
"q": "^1.4.1", "q": "^1.4.1",
"request": "^2.72.0", "request": "^2.72.0",
"require-reload": "0.2.2", "require-reload": "0.2.2",
"typings-global": "^1.0.3", "typings-global": "^1.0.5",
"vinyl": "^1.1.1", "vinyl": "^1.1.1",
"vinyl-file": "^2.0.0" "vinyl-file": "^2.0.0"
}, },

File diff suppressed because one or more lines are too long

View File

@ -8,8 +8,6 @@ import should = require("should");
let vinyl = require("vinyl"); let vinyl = require("vinyl");
describe("smartfile".yellow,function(){ describe("smartfile".yellow,function(){
describe(".fs".yellow,function(){ describe(".fs".yellow,function(){
describe(".fileExistsSync".yellow,function(){ describe(".fileExistsSync".yellow,function(){
it("should return an accurate boolean",function(){ it("should return an accurate boolean",function(){
@ -58,6 +56,16 @@ describe("smartfile".yellow,function(){
}); });
}); });
}); });
describe(".listFileTree()",function(){
it("should get a file tree",function(done){
smartfile.fs.listFileTree(path.resolve("./test/"),"**/*.txt")
.then(function(folderArrayArg){
folderArrayArg.should.containDeep([ "testfolder/testfile1.txt"]);
folderArrayArg.should.not.containDeep([ "mytest.json"]);
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/")

View File

@ -272,4 +272,17 @@ export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):stri
return allItmesArray; return allItmesArray;
}; };
export let listFileTree = (dirPath:string, miniMatchFilter:string) => {
let done = plugins.q.defer();
let options = {
cwd:dirPath
}
plugins.glob(miniMatchFilter,options,(err,files:string[]) => {
if(err){
console.log(err);
done.reject();
};
done.resolve(files);
});
return done.promise;
};

View File

@ -1,13 +1,14 @@
import "typings-global"; import "typings-global";
export let beautylog = require("beautylog"); export import beautylog = require("beautylog");
export let fs = require("fs-extra"); export let fs = require("fs-extra");
export let gulp = require("gulp"); export let gulp = require("gulp");
export let glob = require("glob");
export let g = { export let g = {
remoteSrc: require("gulp-remote-src") remoteSrc: require("gulp-remote-src")
}; };
export import path = require("path"); export let path = require("path");
export let q = require("q"); export let q = require("q");
export import vinyl = require("vinyl"); export let vinyl = require("vinyl");
export let vinylFile = require("vinyl-file"); export let vinylFile = require("vinyl-file");
export let yaml = require("js-yaml"); export let yaml = require("js-yaml");
export let request = require("request"); export let request = require("request");