Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
Clément Nerma edited this page Jun 24, 2015 · 1 revision

WesyerJS API

Wesyer

void Wesyer.run (task, args, context)

Run a task

Parameters

  • string task : The task name
  • array args : The task's arguments. Must be an array
  • object context : [Optionnal] The this object of the task

Wesyer.Files Wesyer.for(selector)

Select files to works on.

Parameters

Returns Wesyer.Files


[Class] Wesyer.File (input, match, encoding)

Create a file to works on.

Parameters

  • string input : The file path
  • string match : The glob pattern used to find the file (this can be the file path)
  • string encoding : The file encoding. If omitted, this will be the encoding defined in the configuration

string Wesyer.File.path ()

Returns The path of the file


string Wesyer.File.encoding ()

Returns The encoding used to open the file


string Wesyer.File.basename ()

Returns The base name of the file (after all slaches, such as example.txt)


string Wesyer.File.match ()

Returns The glob pattern used to find the file


void Wesyer.File.pipe (module)

Pipe the file with a module

Parameters

  • string module : The module's name

string Wesyer.File.apply (callback)

Apply a callback to the file's content

Parameters

  • function callback : The callback function. It must accept one parameter : the file's content (string)

Returns The content returned by the callback


void|boolean Wesyer.File.do (callback)

Apply a callback to the file's content. The result of the callback is stored as the file's content.

Parameters

  • function callback : The callback function. It must accept one parameter : the file's content (string)

Returns false if an error occured.


void|boolean Wesyer.File.out (output, options)

Write the content of the file in an other folder

Parameters

  • string output : The output file path
  • object options : [Optionnal] Can contains encoding and root parameters. If root is not null and not false, it will write the file at the root of the folder

[Class] Wesyer.Files (from, encoding)

Select files to works on.

Parameters

  • string from : A glob pattern to select files
  • string encoding : The encoding of the files. If omitted, this will be replaced by the encoding defined in the configuration

string Wesyer.Files.match ()

Returns The glob pattern used to select files


string Wesyer.Files.encoding ()

Returns The files' encoding


void Wesyer.Files.pipe (module)

Pipe all files with a module

Parameters

  • string module : The module name

void Wesyer.Files.forEach (callback)

Call the apply function of each file with callback as parameter

Parameters Parameters of Wesyer.File.apply


void|boolean Wesyer.Files.out (output, options)

Call the out function of each file with output and options as parameters.

Parameters Parameters of Wesyer.File.out