Files Class
Ported fileutils methods from Selleck
Item Index
Methods
copyAssets
-
from -
dest -
deleteFirst -
callback
Copy the theme assets directory
Parameters:
-
fromPathThe source directory
-
destPathThe destination directory
-
deleteFirstBooleanShould the directory be deleted if it exists
-
callbackFunctionThe callback to be executed
copyDirectory
-
source -
dest -
[overwrite=false] -
callback
Copy a directory from one location to another
Parameters:
-
sourcePathThe source directory
-
destPathThe destination directory
-
[overwrite=false]Boolean optionalWhether or not to overwrite destination files if they already exist.
-
callbackFunctionThe callback to be executed when complete.
copyFile
-
source -
dest -
[overwrite=false] -
callback
Copy a file from one location to another
Parameters:
-
sourcePathThe source file
-
destPathThe destination file
-
[overwrite=false]Boolean optionalWhether or not to overwrite destination files if they already exist.
-
callbackCallbackThe callback to be executed when complete.
-
errErrorThe Error returned from Node
-
copyPath
-
source -
dest -
[overwrite=false] -
callback
If source is a file, copies it to dest. If it's a directory, recursively copies it and all files and directories it contains to dest.
Note that when attempting to copy a file into a directory, you should specify the full path to the new file (including the new filename). Otherwise, it will be interpreted as an attempt to copy the source file over the dest directory instead of into it.
Known issues:
- Doesn't preserve ownership or permissions on copied files/directories.
Parameters:
-
sourceStringSource path.
-
destStringDestination path.
-
[overwrite=false]Boolean optionalWhether or not to overwrite destination files if they already exist.
-
callbackCallbackThe callback to execute when completed.
-
errError
-
deletePath
-
path
If path is a file, deletes it. If path is a directory, recursively deletes it and all files and directories it contains.
This method is synchronous.
Parameters:
-
pathStringFile or directory to delete.
getJSON
-
filename
Helper method for getting JSON data from a local file
Parameters:
-
filenamePathThe filename to parse JSON from
Returns:
The JSON data
isDirectory
-
path -
[link=false]
Check to see if this is a directory
Parameters:
-
pathPathThe path to check
-
[link=false]Boolean optionalAlso validate a symlink
Returns:
True if it is a directory
isFile
-
path -
[link=false]
Check to see if this is a File
Parameters:
-
pathPathThe path to check
-
[link=false]Boolean optionalAlso validate a symlink
Returns:
True if it is a file
isSymbolicLink
-
path
Check to see if this is a SymLink
Parameters:
-
pathPathThe path to check
Returns:
True if it is a link
lstatSync
-
path
Like fs.lstatSync(), but returns null instead of throwing when path
doesn't exist. Will still throw on other types of errors.
Parameters:
-
pathStringPath to stat.
Returns:
fs.Stats object, or null if path doesn't exist.
statSync
-
path
Like fs.statSync(), but returns null instead of throwing when path
doesn't exist. Will still throw on other types of errors.
Parameters:
-
pathStringPath to stat.
Returns:
fs.Stats object, or null if path doesn't exist.
writeFile
-
file -
data -
callback
Helper method for writing files to disk. It wraps the NodeJS file API
Parameters:
-
filePathThe filename to write to
-
dataStringThe data to write
-
callbackCallback multiple
