API Docs for:
Show:

Files Class

Ported fileutils methods from Selleck

Methods

copyAssets

(
  • from
  • dest
  • deleteFirst
  • callback
)

Copy the theme assets directory

Parameters:

  • from Path

    The source directory

  • dest Path

    The destination directory

  • deleteFirst Boolean

    Should the directory be deleted if it exists

  • callback Function

    The callback to be executed

copyDirectory

(
  • source
  • dest
  • [overwrite=false]
  • callback
)

Copy a directory from one location to another

Parameters:

  • source Path

    The source directory

  • dest Path

    The destination directory

  • [overwrite=false] Boolean optional

    Whether or not to overwrite destination files if they already exist.

  • callback Function

    The callback to be executed when complete.

copyFile

(
  • source
  • dest
  • [overwrite=false]
  • callback
)

Copy a file from one location to another

Parameters:

  • source Path

    The source file

  • dest Path

    The destination file

  • [overwrite=false] Boolean optional

    Whether or not to overwrite destination files if they already exist.

  • callback Callback

    The callback to be executed when complete.

    • err Error

      The 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:

  • source String

    Source path.

  • dest String

    Destination path.

  • [overwrite=false] Boolean optional

    Whether or not to overwrite destination files if they already exist.

  • callback Callback

    The callback to execute when completed.

    • err Error

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 String

    File or directory to delete.

getJSON

(
  • filename
)
Object

Helper method for getting JSON data from a local file

Parameters:

  • filename Path

    The filename to parse JSON from

Returns:

Object:

The JSON data

isDirectory

(
  • path
  • [link=false]
)
Boolean

Check to see if this is a directory

Parameters:

  • path Path

    The path to check

  • [link=false] Boolean optional

    Also validate a symlink

Returns:

Boolean:

True if it is a directory

isFile

(
  • path
  • [link=false]
)
Boolean

Check to see if this is a File

Parameters:

  • path Path

    The path to check

  • [link=false] Boolean optional

    Also validate a symlink

Returns:

Boolean:

True if it is a file

lstatSync

(
  • path
)
fs.Stats | Null

Like fs.lstatSync(), but returns null instead of throwing when path doesn't exist. Will still throw on other types of errors.

Parameters:

  • path String

    Path to stat.

Returns:

fs.Stats | Null:

fs.Stats object, or null if path doesn't exist.

statSync

(
  • path
)
fs.Stats | Null

Like fs.statSync(), but returns null instead of throwing when path doesn't exist. Will still throw on other types of errors.

Parameters:

  • path String

    Path to stat.

Returns:

fs.Stats | Null:

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:

  • file Path

    The filename to write to

  • data String

    The data to write

  • callback Callback multiple