0.2.7 • Published 2 months ago

fs-assistant v0.2.7

Weekly downloads
4
License
MIT
Repository
github
Last release
2 months ago

fs-assistant

npm.io npm.io npm.io npm.io npm.io

fs-assistant is a simple library that gives you recursive folder copying, simplified file overrides and promisified fs functions.

replaceStringInFile (pathToFile: string, stringPattern: RegExp | string, newString: string) => Promise<void>

Replaces a string in a file that matches the pattern with the new given string.

copyDir (pathToDir: string, pathToNewDir: string) => Promise<void>

Recursively copies all files from a directory to another.

readFile (fileLocation: string) => Promise<string>

Promisified version of fs readFile.

writeFile (newFileLocation: string, contents:any) => Promise<void>

Promisified version of fs writeFile.

copyFile (from: string, to: string) => Promise<void>

Promisified version of fs copyFile.

makeDir (location: string) => Promise<void>

Promisified version of fs makeDir.

deleteFile (location: string) => Promise<void>

Deletes the specified file.

renameFile (fileLocation: string, newFileName: string) => Promise<void>

Renames the specified file

isPath (stringToCheck: string) => boolean

Checks if the given string is a valid path. You can check all covered cases here.

flattenDir (dirLocation: string, newLocation: string) => Promise<void>

Moves all files from a directory (recursively) to a new directory. For example if you have the directory ./myFiles with a file ./myFiles/myFile.txt and a nested directory ./myFiles/nestedFiles which contains ./myFiles/nestedFiles/nestedFile.txt the flattenDir function will move both files to the same level in a new output directory.

getFilesInDir(dirLocation: string) => Promise<FileDetails[]>

Returns an array with all file names and locations in a directory (recursively). Note that the location property in FileDetails represents the path + the name of the file.

readDir(dir: string) => Promise<string[]>

The promisified version of fs.readdir.

getDirsInDir(dirLocation: string) => Promise<FileDetails[]>

Returns an array with all sub directories of a directory.

getFilesInDir(dirLocation: string) => Promise<DirectoryDetails[]>

Returns an array with all items represented either as FileDetails or as DirectoryDetails.

getFileSizeInBytes: (location: string) => Promise<number>;

Returns the file size in bytes.

getDirSizeInBytes: (location: string) => Promise<number>;

Returns the directory size in bytes.

delDir: (location: string) => Promise<void>;

Deletes the directory recursively.

existsSync: (location: string) => boolean;

Equivalent to fs.existsSync().

0.2.7

2 months ago

0.2.6

3 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.9

5 years ago

0.1.8

5 years ago

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.0

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago