menuReference
Tutorialkeyboard_arrow_right
Concepts and Featureskeyboard_arrow_right
How Tokeyboard_arrow_right

Classes

InitCliEventHookEvent

This event is sent when the command line is started.

It is used by plugins to register available commands.

HookEvent

Base class for events dispatched using the HookRunner class.

HookRunner

For running hooks.

This is similar to the starnard JavaScript EventTarget class, with a few differences.

ProjectHookRunner

Serves as the event target for all events dispatched during the project phase.

Functions

runCommand(command, args, [options])

Run a shell command.

This is a wrapper for the nodejs spawn function.

resolveHookEntryPoints([cwd], [importPath], [conditions], [options])

Resolve files that serve as hook entry points.

This function will resolve files corresponding to a particular exported path from a node package. It will also search for the export path for all dependencies of that package.

The function can be configured to only search for exports with a specific condition, and to consider only those dependencies with a specific keyword.

pkgSetExport(exps, options)

Update the exports section from a package.json file. This is useful for scaffolding.

InitCliEvent ⇐ HookEvent

This event is sent when the command line is started.

It is used by plugins to register available commands.

Kind: global class
Extends: HookEvent

initCliEvent.program

An instance of a Commander command where extra commands can be added.

Kind: instance property of InitCliEvent

initCliEvent.target : HookRunner

An instance of HookRunner where the event is dispatched.

Kind: instance property of InitCliEvent
Overrides: target

HookEvent

Base class for events dispatched using the HookRunner class.

Kind: global class

hookEvent.target : HookRunner

An instance of HookRunner where the event is dispatched.

Kind: instance property of HookEvent

HookRunner

For running hooks.

This is similar to the starnard JavaScript EventTarget class, with a few differences.

Kind: global class

hookRunner.addListener(type, listener)

Add hook listener.

Kind: instance method of HookRunner

Param Description
type The hook event to listen to.
listener The function to call when the event triggers.

hookRunner.addListenerModule(mod)

Adds all exported functions from the module as listeners. Each function will be added as a listener to the event corresponding to the name of the function.

Kind: instance method of HookRunner

Param Description
mod the module to add listeners from

hookRunner.dispatch(hookEvent, options)

Dispatch a hook event. Note that this is an async function. The event listeners will be run in order of priority. If the concurrent parameter is set, they will be run in parallel, otherwise sequentially.

Kind: instance method of HookRunner

Param Type Description
hookEvent HookEvent The event to dispatch.
options Object
options.concurrent Weather to run events in parallel.

ProjectHookRunner

Serves as the event target for all events dispatched during the project phase.

Kind: global class

projectHookRunner.cwd()

Get the working directory where the project is run.

Kind: instance method of ProjectHookRunner

runCommand(command, args, [options]) ⇒

Run a shell command.

This is a wrapper for the nodejs spawn function.

Kind: global function
Returns: The output from the command.

Param Type Description
command The command to run.
args Arguments for the command.
[options] Object
options.passthrough Passthrough data on stdout to the console, at the same time as collecting it to be returned.

resolveHookEntryPoints([cwd], [importPath], [conditions], [options])

Resolve files that serve as hook entry points.

This function will resolve files corresponding to a particular exported path from a node package. It will also search for the export path for all dependencies of that package.

The function can be configured to only search for exports with a specific condition, and to consider only those dependencies with a specific keyword.

Kind: global function

Param Type Description
[cwd]
[importPath]
[conditions]
[options] Object
options.cwd Package directory.
options.importPath The path to import.
options.conditions Conditions to apply, according to the node package resolution algorithm.
options.keyword Only consider dependencies with this keyword.
options.fs Reference to the fs object to use.

pkgSetExport(exps, options) ⇒

Update the exports section from a package.json file. This is useful for scaffolding.

Kind: global function
Returns: The updated exports section.

Param Type Description
exps The exports section.
options Object
options.importPath The importPath to update.
options.conditions The conditions to update.
options.target The target that the importPath should import.