Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • VFile

Callable

  • VFile<F>(input?: F | VFileContents | VFileOptions): F
  • Create a new virtual file. If options is string or Buffer, treats it as {contents: options}. If options is a VFile, returns it. All other options are set on the newly created vfile.

    Path related properties are set in the following order (least specific to most specific): history, path, basename, stem, extname, dirname.

    It’s not possible to set either dirname or extname without setting either history, path, basename, or stem as well.

    Type parameters

    Parameters

    • Optional input: F | VFileContents | VFileOptions

    Returns F

Indexable

[key: string]: unknown

Index

Properties

Optional basename

basename: string

Current name (including extension) of vfile. Cannot contain path separators. Cannot be nullified either (use file.path = file.dirname instead).

contents

contents: VFileContents

Raw value.

cwd

cwd: string

Base of path. Defaults to process.cwd().

data

data: unknown

Place to store custom information. It's OK to store custom data directly on the vfile, moving it to data gives a little more privacy.

Optional dirname

dirname: string

Path to parent directory of vfile. Cannot be set if there's no path yet.

Optional extname

extname: string

Extension (with dot) of vfile. Cannot be set if there's no path yet and cannot contain path separators.

fail

fail: (reason: string, position?: Point | Position | Node, ruleId?: string) => never

Associates a fatal message with the file, then immediately throws it. Note: fatal errors mean a file is no longer processable. Calls message() internally.

param

Reason for message. Uses the stack and message of the error if given.

param

Place at which the message occurred in vfile.

param

Category of message.

Type declaration

    • (reason: string, position?: Point | Position | Node, ruleId?: string): never
    • Parameters

      • reason: string
      • Optional position: Point | Position | Node
      • Optional ruleId: string

      Returns never

history

history: string[]

List of file-paths the file moved between.

info

info: (reason: string, position?: Point | Position | Node, ruleId?: string) => VFileMessage

Associates an informational message with the file, where fatal is set to null. Calls message() internally.

param

Reason for message. Uses the stack and message of the error if given.

param

Place at which the message occurred in vfile.

param

Category of message.

Type declaration

    • (reason: string, position?: Point | Position | Node, ruleId?: string): VFileMessage
    • Parameters

      • reason: string
      • Optional position: Point | Position | Node
      • Optional ruleId: string

      Returns VFileMessage

message

message: (reason: string, position?: Point | Position | Node, ruleId?: string) => VFileMessage

Associates a message with the file for reason at position. When an error is passed in as reason, copies the stack. Each message has a fatal property which by default is set to false (ie. warning).

param

Reason for message. Uses the stack and message of the error if given.

param

Place at which the message occurred in vfile.

param

Category of message.

Type declaration

    • (reason: string, position?: Point | Position | Node, ruleId?: string): VFileMessage
    • Parameters

      • reason: string
      • Optional position: Point | Position | Node
      • Optional ruleId: string

      Returns VFileMessage

messages

messages: VFileMessage[]

List of messages associated with the file.

Optional path

path: string

Path of vfile. Cannot be nullified.

Optional stem

stem: string

Name (without extension) of vfile. Cannot be nullified, and cannot contain path separators.

toString

toString: (encoding?: BufferEncoding) => string

Convert contents of vfile to string.

param

If contents is a buffer, encoding is used to stringify buffers (default: 'utf8').

Type declaration

    • (encoding?: BufferEncoding): string
    • Parameters

      • Optional encoding: BufferEncoding

      Returns string

Generated using TypeDoc