Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
ff2e34696a | |||
23188dfe3f | |||
38f10e0d04 | |||
2e2b8351f8 | |||
8c386ee91c | |||
9828689f31 | |||
8205da5284 |
25
dist/smartfile.fs.d.ts
vendored
25
dist/smartfile.fs.d.ts
vendored
@ -80,9 +80,30 @@ export declare let requireReload: (path: string) => any;
|
|||||||
* lists Folders in a directory on local disk
|
* lists Folders in a directory on local disk
|
||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
export declare let listFolders: (pathArg: string) => any;
|
export declare let listFolders: (pathArg: string, regexFilter?: RegExp) => any;
|
||||||
/**
|
/**
|
||||||
* lists Folders SYNCHRONOUSLY in a directory on local disk
|
* lists Folders SYNCHRONOUSLY in a directory on local disk
|
||||||
* @returns an array with the folder names as strings
|
* @returns an array with the folder names as strings
|
||||||
*/
|
*/
|
||||||
export declare let listFoldersSync: (pathArg: any) => string[];
|
export declare let listFoldersSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
||||||
|
/**
|
||||||
|
* lists Files in a directory on local disk
|
||||||
|
* @returns Promise
|
||||||
|
*/
|
||||||
|
export declare let listFiles: (pathArg: string, regexFilter?: RegExp) => any;
|
||||||
|
/**
|
||||||
|
* lists Files SYNCHRONOUSLY in a directory on local disk
|
||||||
|
* @returns an array with the folder names as strings
|
||||||
|
*/
|
||||||
|
export declare let listFilesSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
||||||
|
/**
|
||||||
|
* lists all items (folders AND files) in a directory on local disk
|
||||||
|
* @returns Promise
|
||||||
|
*/
|
||||||
|
export declare let listAllItems: (pathArg: string, regexFilter?: RegExp) => any;
|
||||||
|
/**
|
||||||
|
* lists all items (folders AND files) SYNCHRONOUSLY in a directory on local disk
|
||||||
|
* @returns an array with the folder names as strings
|
||||||
|
*/
|
||||||
|
export declare let listAllItemsSync: (pathArg: string, regexFilter?: RegExp) => string[];
|
||||||
|
export declare let listFileTree: (dirPath: string, miniMatchFilter: string) => any;
|
||||||
|
101
dist/smartfile.fs.js
vendored
101
dist/smartfile.fs.js
vendored
File diff suppressed because one or more lines are too long
9
dist/smartfile.memory.d.ts
vendored
9
dist/smartfile.memory.d.ts
vendored
@ -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;
|
||||||
|
7
dist/smartfile.plugins.d.ts
vendored
7
dist/smartfile.plugins.d.ts
vendored
@ -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;
|
||||||
|
3
dist/smartfile.plugins.js
vendored
3
dist/smartfile.plugins.js
vendored
@ -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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDYixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxVQUFFLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ3pCLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDdkIsU0FBQyxHQUFHO0lBQ1gsU0FBUyxFQUFFLE9BQU8sQ0FBQyxpQkFBaUIsQ0FBQztDQUN4QyxDQUFDO0FBQ1ksWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQzFCLFNBQUMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUM7QUFDZCxhQUFLLFdBQVcsT0FBTyxDQUFDLENBQUM7QUFDNUIsaUJBQVMsR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLENBQUM7QUFDbEMsWUFBSSxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUMxQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLHFCQUFhLEdBQUcsT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBQUMiLCJmaWxlIjoic21hcnRmaWxlLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiO1xuZXhwb3J0IGxldCBiZWF1dHlsb2cgPSByZXF1aXJlKFwiYmVhdXR5bG9nXCIpO1xuZXhwb3J0IGxldC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uZXhwb3J0IGxldCByZXF1ZXN0ID0gcmVxdWlyZShcInJlcXVlc3RcIik7XG5leHBvcnQgbGV0IHJlcXVpcmVSZWxvYWQgPSByZXF1aXJlKFwicmVxdWlyZS1yZWxvYWRcIik7XG4iXX0=
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"mode":"default",
|
"mode":"default",
|
||||||
"codecov":true,
|
"codecov":true,
|
||||||
"coverageTreshold":80
|
"coverageTreshold":70
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartfile",
|
"name": "smartfile",
|
||||||
"version": "4.0.6",
|
"version": "4.0.9",
|
||||||
"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",
|
||||||
@ -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"
|
||||||
},
|
},
|
||||||
|
30
test/test.js
30
test/test.js
File diff suppressed because one or more lines are too long
30
test/test.ts
30
test/test.ts
@ -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(){
|
||||||
@ -40,6 +38,34 @@ 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(".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/")
|
||||||
|
@ -175,11 +175,16 @@ export let requireReload = function(path:string){
|
|||||||
* lists Folders in a directory on local disk
|
* lists Folders in a directory on local disk
|
||||||
* @returns Promise
|
* @returns Promise
|
||||||
*/
|
*/
|
||||||
export let listFolders = function(pathArg:string){
|
export let listFolders = function(pathArg:string,regexFilter?:RegExp){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
let folderArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
let folderArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
});
|
});
|
||||||
|
if(regexFilter){
|
||||||
|
folderArray = folderArray.filter((fileItem) => {
|
||||||
|
return regexFilter.test(fileItem);
|
||||||
|
});
|
||||||
|
}
|
||||||
done.resolve(folderArray);
|
done.resolve(folderArray);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
@ -188,8 +193,96 @@ export let listFolders = function(pathArg:string){
|
|||||||
* lists Folders SYNCHRONOUSLY in a directory on local disk
|
* lists Folders SYNCHRONOUSLY in a directory on local disk
|
||||||
* @returns an array with the folder names as strings
|
* @returns an array with the folder names as strings
|
||||||
*/
|
*/
|
||||||
export let listFoldersSync = function(pathArg):string[]{
|
export let listFoldersSync = function(pathArg:string,regexFilter?:RegExp):string[]{
|
||||||
return plugins.fs.readdirSync(pathArg).filter(function(file) {
|
let folderArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
|
||||||
});
|
});
|
||||||
|
if(regexFilter){
|
||||||
|
folderArray = folderArray.filter((fileItem) => {
|
||||||
|
return regexFilter.test(fileItem);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return folderArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists Files in a directory on local disk
|
||||||
|
* @returns Promise
|
||||||
|
*/
|
||||||
|
export let listFiles = function(pathArg:string, regexFilter?:RegExp){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
let fileArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isFile();
|
||||||
|
});
|
||||||
|
if(regexFilter){
|
||||||
|
fileArray = fileArray.filter((fileItem) => {
|
||||||
|
return regexFilter.test(fileItem);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
done.resolve(fileArray);
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists Files SYNCHRONOUSLY in a directory on local disk
|
||||||
|
* @returns an array with the folder names as strings
|
||||||
|
*/
|
||||||
|
export let listFilesSync = function(pathArg:string, regexFilter?:RegExp):string[]{
|
||||||
|
let fileArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isFile();
|
||||||
|
});
|
||||||
|
if(regexFilter){
|
||||||
|
fileArray = fileArray.filter((fileItem) => {
|
||||||
|
return regexFilter.test(fileItem);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return fileArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists all items (folders AND files) in a directory on local disk
|
||||||
|
* @returns Promise
|
||||||
|
*/
|
||||||
|
export let listAllItems = function(pathArg:string, regexFilter?:RegExp){
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
let allItmesArray = plugins.fs.readdirSync(pathArg);
|
||||||
|
if(regexFilter){
|
||||||
|
allItmesArray = allItmesArray.filter((fileItem) => {
|
||||||
|
return regexFilter.test(fileItem);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
done.resolve(allItmesArray);
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists all items (folders AND files) SYNCHRONOUSLY in a directory on local disk
|
||||||
|
* @returns an array with the folder names as strings
|
||||||
|
*/
|
||||||
|
export let listAllItemsSync = function(pathArg:string, regexFilter?:RegExp):string[]{
|
||||||
|
let allItmesArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
|
||||||
|
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isFile();
|
||||||
|
});
|
||||||
|
if(regexFilter){
|
||||||
|
allItmesArray = allItmesArray.filter((fileItem) => {
|
||||||
|
return regexFilter.test(fileItem);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
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;
|
||||||
|
};
|
@ -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");
|
||||||
|
@ -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