FSEP
Is a library that promisifies the native node FS operation and brings extras into the mix. Fsep has No Dependency.
Features
- Native node.js Fs methods (promisified)
- Only Promises
TODO
- copy
- ensureLink
- move
- outputJson
- readJson
- remove
- writeJson
API
-
walk
-
exist
-
mkdirs
-
emptyFolder
-
outputFile
-
outputFolder
-
ensureFile
-
ensureFolder
-
ensureSymlink
-
scaffold
-
readFiles
-
readWriteLine
-
readFolder
-
removeFile
-
removeFolder
-
writeFolder
walk(path, [options])
options: Object
path: String
Path to directoryfilters: Array
RegExp stringsrelative: Boolean
Return paths relative or absolute. Default isfalse
ignoreDot: Boolean
Ignores files beginning with a dot. Default istrue
const Fsep = ;const path = '/home/user/directory';const options = relative: false ignoreDot: true filters: '.DS_Store'; Fsep;
exist(path)
Checks if a path exists. Returns true
or false
. Uses Fs.stat
.
const Fsep = ; Fsep;
mkdirs(path [,mode])
Creates the path folders if they do not exist. Accepts a mode
parameter.
const Fsep = ;const path = '/non/existing/dir'; Fsep;
outputFile(path, data, [options])
Creates a file and also directories if non existent. Overwrites file if it exists.
const Fsep = ; var path = '/non/existing/path/file.js';var data = 'hello'; Fsep;
outputFolder(path [,mode, cwd])
Creates folders in path if they do not exist.
const Fsep = ;const path = '/non/existing/dir'; Fsep;
ensureFolder(path, [,mode, cwd])
Creates folders in path if they do not exist.
const Fsep = ;const path = '/non/existing/dir'; Fsep;
ensureFile(path, data, [options], [mode || cwd])
Ensures that the file and its directory structure exists. If the file already exists it is not modified.
const Fsep = ; var path = '/non/existing/dirs/and/file.txt'; Fsep;
ensureSymlink(source, target, type, [mode || cwd])
Ensures that the symlink and its directory structure exists. If the file already exists it is not modified.
const Fsep = ;const src = '/existing/folders/file.txt';const dst = '/non/existing/folders/file.txt'; Fsep;
emptyFolder(path, safe)
Deletes the contents of a directory if it exists and is not empty. This is recursive so be careful. Same as rm -r
.
path: String
Path to the direcotry to empty.safe: Boolean
Default is true which throws an error if you try to empty the root of the file system.
const Fsep = ; var path = '/home/username/dirs'; // contains folders and files Fsep;
scaffold(path, data)
Requires a path and an object or array. Makes files and folders based on object or array. End points are assumed to be file names.
const Fsep = ; const data = one: 'one.txt' two: 'two.txt' array: 'three.txt' 'four.txt' ; Fsep;
readFiles(paths, options)
Reads an array of files asynchronously. The result is an array of files.
const Fsep = ; var paths = '/one.txt' 'two.txt'; Fsep;
readWriteLine(options)
Reads and writes a file line by line. The line
function allows line manipulation.
const Fsep = ; var options = read: // node stream options path: './rw/one.txt' write: // node stream options path: './rw/two.txt' flags: 'a' { return line; }; Fsep;
readFolder
Alias for Fs.readdir
.
removeFile
Alias for Fs.unlink
.
removeFolder
Alias for Fs.rmdir
.
writeFolder
Alias for Fs.mkdir
.
Authors
License
Why You Should Choose MPL-2.0 This project is licensed under the MPL-2.0 License