FileUtil
FileUtil - Provides several utility methods for archiving, copying, reading, and writing files.
Constructor Summary
Public Constructor | ||
public |
constructor(options: FileUtilOptions) Instantiate FileUtil. |
Member Summary
Public Members | ||
public |
Provides a unique counter for temporary archives. |
|
public |
Stores the stack of archiver instances. |
Private Members | ||
private |
_options: FileUtilOptions Stores FileUtil options. |
Method Summary
Public Methods | ||
public |
archiveCreate(destPath: string, addToParent: boolean, silent: boolean) Create a compressed archive relative to the output destination. |
|
public |
archiveFinalize(silent: boolean): Promise Finalizes an active archive. |
|
public |
Copy a source path / to destination path or relative path. |
|
public |
getOptions(): FileUtilOptions Returns a copy of the FileUtil options. |
|
public |
Hydrates a list of files finally defined as globs. |
|
public |
onPluginLoad(ev: PluginEvent) Adds event bindings for FileUtil via |
|
public |
Read lines from a file given a start and end line number. |
|
public |
setOptions(options: FileUtilOptions) Set optional parameters. |
|
public |
Write a file to file path or relative path. |
Private Methods | ||
private |
_getArchive(): * Gets the current archiver instance. |
|
private |
_popArchive(): * Pops an archiver instance off the stack. |
Public Constructors
public constructor(options: FileUtilOptions) source
Instantiate FileUtil.
Params:
Name | Type | Attribute | Description |
options | FileUtilOptions | FileUtilOptions to set. |
Public Members
Private Members
Public Methods
public archiveCreate(destPath: string, addToParent: boolean, silent: boolean) source
Create a compressed archive relative to the output destination. All subsequent file write and copy operations
will add to the existing archive. You must invoke archiveFinalize
to complete the archive process.
Params:
Name | Type | Attribute | Description |
destPath | string | Destination path and file name; the compress format extension will be appended. |
|
addToParent | boolean |
|
If a parent archiver exists then add child archive to it and delete local file. |
silent | boolean |
|
When true |
public archiveFinalize(silent: boolean): Promise source
Finalizes an active archive. You must first invoke archiveCreate
.
Params:
Name | Type | Attribute | Description |
silent | boolean |
|
When true |
Return:
Promise | A resolved promise is returned which is triggered once archive finalization completes. |
public copy(srcPath: string, destPath: string, silent: boolean) source
Copy a source path / to destination path or relative path.
public getOptions(): FileUtilOptions source
Returns a copy of the FileUtil options.
Return:
FileUtilOptions | FileUtil options. |
public hydrateGlob(globs: string | Array<string>): {files: Array<string>, globs: Array<string>} source
Hydrates a list of files finally defined as globs. Bare directory paths will be converted to globs.
public onPluginLoad(ev: PluginEvent) source
Adds event bindings for FileUtil via typhonjs-plugin-manager
.
Params:
Name | Type | Attribute | Description |
ev | PluginEvent | A plugin event. |
public readLines(filePath: string, lineStart: number, lineEnd: number): String[] source
Read lines from a file given a start and end line number.
public setOptions(options: FileUtilOptions) source
Set optional parameters.
Params:
Name | Type | Attribute | Description |
options | FileUtilOptions | Defines optional parameters to set. |
public writeFile(fileData: object, filePath: string, silent: boolean, encoding: string) source
Write a file to file path or relative path.