Class: FileUtils
Defined in: core/src/FileUtils.ts:15
Utility functions for working with files.
Constructors
Constructor
new FileUtils():
FileUtils
Returns
FileUtils
Methods
copyBinaryFile()
staticcopyBinaryFile(srcPath,outPath,variables?,rootDir?):Promise<void>
Defined in: core/src/FileUtils.ts:133
Generates a copy of the source file at the desired output destination using binary copy mode.
Parameters
srcPath
string
The source file to copy.
outPath
string
The destination file to generate.
variables?
any = {}
The map of variable names to values to swap. Applies to outPath only.
rootDir?
string
Optional. When provided, all resolved source and destination paths must be contained within this directory, otherwise an error is thrown.
Returns
Promise<void>
copyDirectory()
staticcopyDirectory(srcPath,outPath,vars?,excludeFilters?,binaryFilters?,force?,rootDir?):Promise<void>
Defined in: core/src/FileUtils.ts:172
Performs a deep copy of a directory tree at the given srcPath to the specified output directory. Performs template replacement for all variables given and skips any files in the specified filter.
Parameters
srcPath
string
The path to the source directory to copy files from.
outPath
string
The path to the destination directory to copy files to.
vars?
any = {}
The map of template variables to perform replacement on.
excludeFilters?
string[] = []
The list of file extension filters to exclude during the copy process.
binaryFilters?
string[] = []
The list of file extension filters to copy as binary only.
force?
boolean = false
Set to true to force writing over any existing files.
rootDir?
string
Optional. When provided, all resolved source and destination paths must be contained within this directory, otherwise an error is thrown.
Returns
Promise<void>
copyFile()
staticcopyFile(srcPath,outPath,variables?,overwrite?,rootDir?):Promise<void>
Defined in: core/src/FileUtils.ts:90
Generates a copy of the source file at the desired output destination and performs a swap of all values of the variables specified.
Parameters
srcPath
string
The source file to copy.
outPath
string
The destination file to generate.
variables?
any = {}
The map of variable names to values to swap.
overwrite?
boolean = false
Set to true to overwrite an existing file at outPath.
rootDir?
string
Optional. When provided, all resolved source and destination paths must be contained within this directory, otherwise an error is thrown.
Returns
Promise<void>
writeFile()
staticwriteFile(srcPath,outPath,contents,overwrite?,rootDir?):Promise<void>
Defined in: core/src/FileUtils.ts:45
Attempts to write the provided contents to the file path given. If a file already exists at the destination
an error is thrown unless overwrite is set to true.
Parameters
srcPath
string
The baseline template file the contents were generated from.
outPath
string
The destination file path to be written.
contents
any
The contents of the file to write.
overwrite?
boolean = false
Set to true to overwrite an existing file at outPath.
rootDir?
string
Optional. When provided, srcPath and outPath must both resolve to a location
contained within this directory, otherwise an error is thrown. Callers that pass externally-influenced paths
should always supply this to prevent path traversal.
Returns
Promise<void>