Home Reference Source Repository
import FileSizePlugin from 'broccoli-file-size/src/index.js'
public class | source

FileSizePlugin

Extends:

broccoli-plugin~Plugin → FileSizePlugin

A Broccoli plugin that display sizes of all files found in its input path.

Constructor Summary

Public Constructor
public

constructor(inputNodes: Node | Node[], options: Object)

Create a new FileSizePlugin instances

Member Summary

Public Members
public

Broccoli plugin options

Method Summary

Public Methods
public

Builds this node.

public

listFiles(dir: String, callback: Function): Promise

Lists files of a directory recursively.

public

print(relativePath: String, size: Number], gzippedSize: Number)

Prints calculated sizes

public

processFile(absolutePath: String): Promise

Either reads the given file's contents and calculating its gzipped sie (when gzipped options is true), or stats the given file (if gzipped option is false).

public

symlinkOrCopy(dir: String, target: String)

Symlink or copy a directory

Public Constructors

public constructor(inputNodes: Node | Node[], options: Object) source

Create a new FileSizePlugin instances

Params:

NameTypeAttributeDescription
inputNodes Node | Node[]

Input nodes, see broccoli-plugin docs

options Object

Plugin options

Public Members

public options: Object source

Broccoli plugin options

Properties:

NameTypeAttributeDescription
gzipped Boolean
  • optional
  • default: true

Whether to display gzipped size or not

colors Boolean
  • optional
  • default: true

Whether to use colors or not

Public Methods

public build(): Promise source

Builds this node.

Symlinks the first input path to this node's output path, then look for all files in the input path, and process each of them by either:

  • reading the file's contents and calculating its gzipped sie (when gzipped options is true)
  • or, stating the file (if gzipped option is false). Then, display size(s) on standard output.

Return:

Promise

A new Promise that is resolved once all input files have been processed, and sizes have been displayed. Alternatively, it can be rejected in case of errors.

public listFiles(dir: String, callback: Function): Promise source

Lists files of a directory recursively. Follows symbolic links.

Params:

NameTypeAttributeDescription
dir String

Directory to scan

callback Function

Callback executed when a file is found. Can return a Promise.

Return:

Promise

A new promise that is resolved once the given directory has been scanned entirely and all callbacks have completed.

public print(relativePath: String, size: Number], gzippedSize: Number) source

Prints calculated sizes

Params:

NameTypeAttributeDescription
relativePath String

Relative path of the input file

size Number]

Size of the input file in bytes

gzippedSize Number
  • optional

Size of the gzipped version of the file

public processFile(absolutePath: String): Promise source

Either reads the given file's contents and calculating its gzipped sie (when gzipped options is true), or stats the given file (if gzipped option is false).

Params:

NameTypeAttributeDescription
absolutePath String

Absolute path to the file

Return:

Promise

A new Promise that is resolved when file has been processed. The resolved value is an array containing the file size and the gzipped file size (or undefined)

public symlinkOrCopy(dir: String, target: String) source

Symlink or copy a directory

Params:

NameTypeAttributeDescription
dir String

Path to an existing

target String

Path of the symlink to create