Functions
The following functions are available globally.
-
Copies the file at the specified source path and pastes it at the destination path.
Declaration
func copy(from srcPath: String, to dstPath: String) -> BoolParameters
srcPathThe relative path to the file within the template.
dstPathThe path at which the file is pasted. If this path begins with a
/it is interpreted as an absolute path, otherwise it is interpreted relative to theoutputFolderPath.Return Value
trueif the file was copied,falseotherwise. -
Creates a new directory, including intermediate directories if necessary.
Declaration
func mkdir(_ path: String) -> BoolParameters
pathThe path of the directory to create. If this path begins with a
/it is interpreted as an absolute path, otherwise it is interpreted relative to theoutputFolderPath.Return Value
trueif the directory was successfully created,falseotherwise. -
Reads the contents of the specified file.
Declaration
func read(contentsOf path: String) -> StringParameters
pathThe relative path to the file within the template.
Return Value
A string representing the contents of the file.
-
Deletes the file at the specified path.
Declaration
func rm(_ path: String) -> BoolParameters
pathThe path to the file to delete. If this path begins with a
/it is interpreted as an absolute path, otherwise it is interpreted relative to theoutputFolderPath.Return Value
trueif the file was successfully deleted,falseotherwise. -
Moves the file at the specified path to the trash.
Declaration
func trash(_ path: String) -> BoolParameters
pathThe path to the file to move to the trash. If this path begins with a
/it is interpreted as an absolute path, otherwise it is interpreted relative to theoutputFolderPath.Return Value
trueif the file was successfully moved to the trash,falseotherwise. -
Writes
datato the file at a specified path.Declaration
func write(data: Data, to path: String) -> BoolParameters
dataThe data to write to the file.
pathThe path to the file to write to. If this path begins with a
/it is interpreted as an absolute path, otherwise it is interpreted relative to theoutputFolderPath.Return Value
trueif the data was successfully written to the file,falseotherwise.