API Docs for: 0.10.0
Show:

Files Class

Defined in: lib/files.js:10
Module: yuidoc

Ported fileutils methods from Selleck

Methods

copyAssets

(
  • from
  • dest
  • deleteFirst
  • callback
)

Defined in lib/files.js:369

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
)

Defined in lib/files.js:39

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
)

Defined in lib/files.js:128

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
)

Defined in lib/files.js:181

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.

deletePath

(
  • path
)

Defined in lib/files.js:227

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

Defined in lib/files.js:417

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

Defined in lib/files.js:252

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

Defined in lib/files.js:283

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

Defined in lib/files.js:326

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

Parameters:

Returns:

fs.Stats | Null:

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

statSync

(
  • path
)
fs.Stats | Null

Defined in lib/files.js:348

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

Parameters:

Returns:

fs.Stats | Null:

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

writeFile

(
  • file
  • data
  • callback
)

Defined in lib/files.js:432

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