Files Class
Ported fileutils methods from Selleck
Item Index
Methods
copyAssets
-
from
-
dest
-
deleteFirst
-
callback
Copy the theme assets directory
copyDirectory
-
source
-
dest
-
[overwrite=false]
-
callback
Copy a directory from one location to another
copyFile
-
source
-
dest
-
[overwrite=false]
-
callback
Copy a file from one location to another
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.
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:
-
path
StringFile or directory to delete.
getJSON
-
filename
Helper method for getting JSON data from a local file
Parameters:
-
filename
PathThe filename to parse JSON from
Returns:
The JSON data
isDirectory
-
path
-
[link=false]
Check to see if this is a directory
Returns:
True if it is a directory
isFile
-
path
-
[link=false]
Check to see if this is a File
Returns:
True if it is a file
isSymbolicLink
-
path
Check to see if this is a SymLink
Parameters:
-
path
PathThe 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:
-
path
StringPath 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:
-
path
StringPath to stat.
Returns:
fs.Stats
object, or null
if path doesn't exist.