rename some actions

This commit is contained in:
Philipp Kunz 2016-06-23 18:39:02 +02:00
parent ef027d32c7
commit 7b4626586c
5 changed files with 81 additions and 28 deletions

View File

@ -1,7 +1,19 @@
import "typings-global";
/**
* copies a file from A to B on the local disk
*/
export declare let copy: (fromArg: string, toArg: string) => any;
/**
* copies a file SYNCHRONOUSLY from A to B on the local disk
*/
export declare let copySync: (fromArg: string, toArg: string) => boolean;
/**
* removes a file or folder from local disk
*/
export declare let remove: (pathArg: string) => any;
/**
* removes a file SYNCHRONOUSLY from local disk
*/
export declare let removeSync: (pathArg: string) => boolean;
export declare let toFS: (options: {
from: string;
@ -40,8 +52,14 @@ export declare let toVinylSync: (filePathArg: any, options?: {}) => any;
* @returns {any}
*/
export declare let requireReload: (path: string) => any;
export declare let foldersSync: (pathArg: any) => any;
export declare let folders: (pathArg: string) => any;
/**
* lists Folders in a directory on local disk
*/
export declare let listFolders: (pathArg: string) => any;
/**
* lists Folders SYNCHRONOUSLY in a directory on local disk
*/
export declare let listFoldersSync: (pathArg: any) => any;
/**
*
* @param filePath

32
dist/smartfile.fs.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,15 +23,15 @@ describe("smartfile".yellow,function(){
(smartfile.fs.fileExists("./test/notthere.json")).should.not.be.fulfilled();
});
});
describe(".foldersSync()",function(){
describe(".listFoldersSync()",function(){
it("should get the file type from a string",function(){
smartfile.fs.foldersSync("./test/").should.containDeep([ "testfolder"]);
smartfile.fs.foldersSync("./test/").should.not.containDeep([ "notExistentFolder"]);
smartfile.fs.listFoldersSync("./test/").should.containDeep([ "testfolder"]);
smartfile.fs.listFoldersSync("./test/").should.not.containDeep([ "notExistentFolder"]);
});
});
describe(".folders()",function(){
describe(".listFolders()",function(){
it("should get the file type from a string",function(done){
smartfile.fs.folders("./test/")
smartfile.fs.listFolders("./test/")
.then(function(folderArrayArg){
folderArrayArg.should.containDeep([ "testfolder"]);
folderArrayArg.should.not.containDeep([ "notExistentFolder"]);

View File

@ -7,6 +7,9 @@ import SmartfileInterpreter = require("./smartfile.interpreter");
============================ FS ACTIONS =========================
===============================================================*/
/**
* copies a file from A to B on the local disk
*/
export let copy = function(fromArg:string, toArg:string){
var done = plugins.q.defer();
plugins.fs.copy(fromArg,toArg,{},function(){
@ -15,11 +18,17 @@ export let copy = function(fromArg:string, toArg:string){
return done.promise;
};
/**
* copies a file SYNCHRONOUSLY from A to B on the local disk
*/
export let copySync = function(fromArg:string,toArg:string):boolean{
plugins.fs.copySync(fromArg,toArg);
return true;
};
/**
* removes a file or folder from local disk
*/
export let remove = function(pathArg:string){
var done = plugins.q.defer();
plugins.fs.remove(pathArg,function(){
@ -28,6 +37,9 @@ export let remove = function(pathArg:string){
return done.promise;
};
/**
* removes a file SYNCHRONOUSLY from local disk
*/
export let removeSync = function(pathArg:string):boolean{
plugins.fs.removeSync(pathArg);
return true;
@ -100,13 +112,10 @@ export let requireReload = function(path:string){
return plugins.requireReload(path);
};
export let foldersSync = function(pathArg){
return plugins.fs.readdirSync(pathArg).filter(function(file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
});
};
export let folders = function(pathArg:string){
/**
* lists Folders in a directory on local disk
*/
export let listFolders = function(pathArg:string){
let done = plugins.q.defer();
let folderArray = plugins.fs.readdirSync(pathArg).filter(function(file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
@ -115,6 +124,14 @@ export let folders = function(pathArg:string){
return done.promise;
};
/**
* lists Folders SYNCHRONOUSLY in a directory on local disk
*/
export let listFoldersSync = function(pathArg){
return plugins.fs.readdirSync(pathArg).filter(function(file) {
return plugins.fs.statSync(plugins.path.join(pathArg, file)).isDirectory();
});
};
/**
*