Hooks
Index
Properties
optionalafterAllInstalled
Type declaration
Called after the
installmethod from theProjectclass successfully completed.Parameters
project: Project
options: InstallOptions
Returns void
optionalcleanGlobalArtifacts
Called when the user requests to clean the global cache. Plugins should use this hook to remove their own global artifacts.
Type declaration
Called when the user requests to clean the global cache. Plugins should use this hook to remove their own global artifacts.
Parameters
configuration: Configuration
Returns Promise<void>
optionalglobalHashGeneration
Called before the build, to compute a global hash key that we will use to detect whether packages must be rebuilt (typically when the Node version changes).
Type declaration
Called before the build, to compute a global hash key that we will use to detect whether packages must be rebuilt (typically when the Node version changes).
Parameters
project: Project
contributeHash: (data: string | Buffer<ArrayBufferLike>) => void
Returns Promise<void>
optionalpopulateYarnPaths
Used to notify the core of all the potential artifacts of the available linkers.
Type declaration
Used to notify the core of all the potential artifacts of the available linkers.
Parameters
project: Project
definePath: (path: null | PortablePath) => void
Returns Promise<void>
optionalreduceDependency
Called during the resolution, once for each resolved package and each of their dependencies. By returning a new dependency descriptor you can replace the original one by a different range.
Note that when multiple plugins are registered on reduceDependency they
will be executed in definition order. In that case, dependency will
always refer to the dependency as it currently is, whereas
initialDependency will be the descriptor before any plugin attempted to
change it.
Type declaration
Called during the resolution, once for each resolved package and each of their dependencies. By returning a new dependency descriptor you can replace the original one by a different range.
Note that when multiple plugins are registered on
reduceDependencythey will be executed in definition order. In that case,dependencywill always refer to the dependency as it currently is, whereasinitialDependencywill be the descriptor before any plugin attempted to change it.Parameters
dependency: Descriptor
project: Project
locator: Locator
initialDependency: Descriptor
extra: { resolveOptions: ResolveOptions; resolver: Resolver }
resolveOptions: ResolveOptions
resolver: Resolver
Returns Promise<Descriptor>
optionalregisterPackageExtensions
Called when the package extensions are setup. Can be used to inject new ones. That's for example what the compat plugin uses to automatically fix packages with known flaws.
Type declaration
Called when the package extensions are setup. Can be used to inject new ones. That's for example what the compat plugin uses to automatically fix packages with known flaws.
Parameters
configuration: Configuration
registerPackageExtension: (descriptor: Descriptor, extensionData: { dependencies?: {}; peerDependencies?: {}; peerDependenciesMeta?: {} }) => void
Returns Promise<void>
optionalsetupScriptEnvironment
Called before a script is executed. The hooks are allowed to modify the
env object as they see fit, and any call to makePathWrapper will cause
a binary of the given name to be injected somewhere within the PATH (we
recommend you don't alter the PATH yourself unless required).
The keys you get in the env are guaranteed to be uppercase. We strongly suggest you adopt this convention for any new key added to the env (we might enforce it later on).
Type declaration
Called before a script is executed. The hooks are allowed to modify the
envobject as they see fit, and any call tomakePathWrapperwill cause a binary of the given name to be injected somewhere within the PATH (we recommend you don't alter the PATH yourself unless required).The keys you get in the env are guaranteed to be uppercase. We strongly suggest you adopt this convention for any new key added to the env (we might enforce it later on).
Parameters
project: Project
env: ProcessEnv
makePathWrapper: (name: string, argv0: string, args: string[]) => Promise<void>
Returns Promise<void>
optionalvalidateProject
Called during the Validation step of the install method from the
Project class.
Type declaration
Called during the
Validation stepof theinstallmethod from theProjectclass.Parameters
project: Project
report: { reportError: (name: MessageName, text: string) => void; reportWarning: (name: MessageName, text: string) => void }
reportError: (name: MessageName, text: string) => void
reportWarning: (name: MessageName, text: string) => void
Returns void
optionalvalidateProjectAfterInstall
Called during the Post-install validation step of the install method
from the Project class.
Type declaration
Called during the
Post-install validation stepof theinstallmethod from theProjectclass.Parameters
project: Project
report: { reportError: (name: MessageName, text: string) => void; reportWarning: (name: MessageName, text: string) => void }
reportError: (name: MessageName, text: string) => void
reportWarning: (name: MessageName, text: string) => void
Returns void
optionalvalidateWorkspace
Called during the Validation step of the install method from the
Project class by the validateProject hook.
Type declaration
Called during the
Validation stepof theinstallmethod from theProjectclass by thevalidateProjecthook.Parameters
workspace: Workspace
report: { reportError: (name: MessageName, text: string) => void; reportWarning: (name: MessageName, text: string) => void }
reportError: (name: MessageName, text: string) => void
reportWarning: (name: MessageName, text: string) => void
Returns void
optionalwrapNetworkRequest
Called when a network request is being made. The executor function
parameter, when called, will trigger the network request. You can use this
mechanism to wrap network requests, for example to run some validation or
add some logging.
Type declaration
Called when a network request is being made. The
executorfunction parameter, when called, will trigger the network request. You can use this mechanism to wrap network requests, for example to run some validation or add some logging.Parameters
executor: () => Promise<Response>
extra: WrapNetworkRequestInfo
Returns Promise<() => Promise<Response>>
optionalwrapScriptExecution
Called as a script is getting executed. The executor function parameter,
when called, will execute the script. You can use this mechanism to wrap
script executions, for example to run some validation or add some
performance monitoring.
Type declaration
Called as a script is getting executed. The
executorfunction parameter, when called, will execute the script. You can use this mechanism to wrap script executions, for example to run some validation or add some performance monitoring.Parameters
executor: () => Promise<number>
project: Project
locator: Locator
scriptName: string
extra: { args: string[]; cwd: PortablePath; env: ProcessEnv; script: string; stderr: Writable; stdin: null | Readable; stdout: Writable }
args: string[]
cwd: PortablePath
env: ProcessEnv
script: string
stderr: Writable
stdin: null | Readable
stdout: Writable
Returns Promise<() => Promise<number>>
Called after the
installmethod from theProjectclass successfully completed.