Installation
$ npm install fs-utilities
Usage
var fs_utils = fs_utils;
API Overview
checkIfIsDirectory( directoryPath, callback )
Asynchronously tests if the specified file is a directory.
Arguments
directoryPath
- fullpath to file which should be testedcallback(err, directoryPath)
- will be executed after test finished. IfdirectoryPath
is not a folder, second callback argument will be undefined.
Example
fs_utils;
checkIfIsDirectorySync( directoryPath )
Synchron function to test if the specified file is a directory.
Arguments
directoryPath
- fullpath to file which should be tested
Example
if fs_utils console;
getSubfolders( directoryPath, callback )
Asynchron function which will pass an array containing all subfolders of the given directory to the also passed callback function.
Arguments
directoryPath
- path to look for subfolderscallback(err, subFolderList)
- will be executed after all subfolders have been detected. If case of an error, the search will be aborted and the second argument of the callback function will be undefined.
Example
fs_utils;
getSubfoldersSync( directoryPath )
Synchronously generates and returns an array containing all subfolders of the given directory.
Arguments
directoryPath
- path to look for subfolders
Example
var folders = fs_utils;console;
traverseAllSubFolders( directoryPath, callback, [opt_excludedDirectories, [opt_finishedCallback]] )
Asynchron function which will recursively traverse all subfolers.
Arguments
directoryPath
- path from where to start traversingcallback(subFolder)
- will be called for each traversedsubfolder
opt_excludedDirectories
- list of folders that will be skipedopt_finishedCallback
- function that is called after all subfolders have been traversed or an error occured
Example
{ console;} { if err throw err; console;} var excludedFolders = "excludedFolder0" "excludedFolder1" ...;fs_utils;
traverseAllSubFoldersSync( directoryPath, callback, [opt_excludedDirectories] )
Synchronous function which will recursively traverse all subfolers.
Arguments
directoryPath
- path from where to start traversingcallback(subFolder)
- will be called for each traversed folderopt_excludedDirectories
- list of folders that will be skiped
Example
{ console;} var excludedFolders = "excludedFolder0" "excludedFolder1" ...;fs_utils;console;
Tests
To run the test suite, first install the dependencies, then run npm test
:
$ npm install$ npm test
Coverage
To run a code coverage analysis execute following commands:
$ npm install$ npm run coverage
JSDoc
To generate a complete API documentation using JSDoc execute following commands:
$ npm install$ npm run jsdoc