Overview
Common functions for file system
Table of contents
- GlobWhere (type alias)
- clearFolder (function)
- createFile (function)
- createFolder (function)
- deleteFile (function)
- deleteFolder (function)
- existFile (function)
- existFolder (function)
- file (function)
- fileStream (function)
- fileString (function)
- folders (function)
- glob (function)
- updateFile (function)
- updateFolder (function)
GlobWhere (type alias)
Signature
export type GlobWhere = { path: string[] | string; options?: GlobOptions }
clearFolder (function)
Delete folder if directory exist and even directory contain files
Signature
export const clearFolder = (strPath: string): void => ...
Added in v0.2.0
createFile (function)
Write a file
Signature
export const createFile = (
{ path, data, encoding }: { path: string, data: string | Buffer, encoding?: string }): void => ...
Added in v0.2.0
createFolder (function)
Create a folder.
Create when folder not exist
Ignore When folder exist
Signature
export const createFolder = (path: string): void => ...
Added in v0.2.0
deleteFile (function)
Delete a file
Signature
export const deleteFile = (path: string): void => ...
Added in v0.2.0
deleteFolder (function)
Delete folder if directory exist and even directory contain files
Signature
export const deleteFolder = (strPath: string): void => ...
Added in v0.2.0
existFile (function)
Check a file exist
Signature
export const existFile = (path: string): boolean => ...
Added in v0.2.0
existFolder (function)
check directory that is existed
Signature
export const existFolder = (path: string): boolean => ...
Added in v0.2.0
file (function)
Get a file info
Signature
export const file = (path: string): {
path: string
size: number
lastModified: Date
} => ...
Added in v0.2.0
fileStream (function)
Get a file stream
Signature
export const fileStream = (path: string): fs.ReadStream => ...
Added in v0.2.0
fileString (function)
Get a file string
Signature
export const fileString = (path: string): string => ...
Added in v0.2.0
folders (function)
List all folders and files in a given folder
Signature
export const folders = (strPath: string): { folders: string[], files: string[] } => ...
Added in v0.2.0
glob (function)
find file or folder using the patterns the shell uses, like stars and stuff.
Signature
export const glob = ({ path, options }: GlobWhere): string[] => ...
Added in v0.2.0
updateFile (function)
update a file.
Rename path when path isn’t undefined
Replace content when data isn’t undefined
Signature
export const updateFile = ({ data: { path, data, encoding }, where }:
{ data: { path?: string, data?: string | Buffer, encoding?: string }, where: string }): void => ...
Added in v0.2.0
updateFolder (function)
rename a folder
Signature
export const updateFolder = ({ name, where }: { name: string, where: string }): void => ...
Added in v0.2.0