Skip to content

Hooks


Hooks are called to enable custom actions at specific times which can be overwritten or intercepted by the application.

hookExists

Determine if a hook exists

Usage

hookExists [ --application applicationHome ] [ --extensions extensionList ] [ --next scriptName ] [ hookName0 ]

Does a hook exist in the local project?

Check if one or more hook exists. All hooks must exist to succeed.

Location: bin/build/tools/hook.sh

Arguments

  • --application applicationHome - Path. Optional. Directory of alternate application home. Can be specified more than once to change state.
  • --extensions extensionList - ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults to BUILD_HOOK_EXTENSIONS.
  • --next scriptName - File. Optional. Locate the script found after the named script, if any. Allows easy chaining of scripts.
  • hookName0 - one or more hook names which must exist

Return codes

  • 0 - If all hooks exist

Environment

See Also

hookEnvironment

Load hook-related environment variables

Usage

hookEnvironment [ --help ]

Load hook environment variables used to find hooks.

Ensures BUILD_HOOK_EXTENSIONS and BUILD_HOOK_DIRS are set to their proper defaults.

If already loaded, this function has no effect.

Location: bin/build/tools/hook.sh

Arguments

  • --help - Flag. Optional. Display this help.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

hookRun

Run a project hook

Usage

hookRun [ --application applicationHome ] [ --extensions extensionList ] [ --next scriptName ] hookName [ ... ] [ --help ]

Run a hook in the project located at ./bin/hooks/

See (Hooks documentation)[../hooks/index.md] for standard hooks.

Hooks provide an easy way to customize your build. Hooks are binary files located in your project directory at ./bin/hooks/ and are named hookName with a .sh extension added. So the hook for version-current would be a file at:

bin/hooks/version-current.sh

Sample hooks (scripts) can be found in the build source code at ./bin/hooks/.

Default hooks (scripts) can be found in the current build version at bin/build/hooks/

Location: bin/build/tools/hook.sh

Arguments

  • --application applicationHome - Path. Optional. Directory of alternate application home.
  • --extensions extensionList - ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults to BUILD_HOOK_EXTENSIONS.
  • --next scriptName - File. Optional. Run the script found after the named script, if any. Allows easy chaining of scripts.
  • hookName - String. Required. Hook name to run.
  • ... - Arguments. Optional. Any arguments to the hook. See each hook implementation for details.
  • --help - Flag. Optional. Display this help.

Debugging settings

Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:

  • hook - hookRun and hookSource and optional versions of the same functions will output additional debugging information

Examples

version="$(hookRun version-current)"

Return codes

  • Any - The hook exit code is returned if it is run
  • 1 - is returned if the hook is not found

Environment

See Also

hookSource

Run a project hook

Usage

hookSource [ --application applicationHome ] [ --extensions extensionList ] hookName ...

Run a hook in the project located at ./bin/hooks/

See (Hooks documentation)[../hooks/index.md] for standard hooks.

Hooks provide an easy way to customize your build. Hooks are binary files located in your project directory at ./bin/hooks/ and are named hookName with a .sh extension added. So the hook for version-current would be a file at:

bin/hooks/version-current.sh

Sample hooks (scripts) can be found in the build source code at ./bin/hooks/.

Default hooks (scripts) can be found in the current build version at bin/build/hooks/

Location: bin/build/tools/hook.sh

Arguments

  • --application applicationHome - Path. Optional. Directory of alternate application home.
  • --extensions extensionList - ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults to BUILD_HOOK_EXTENSIONS.
  • hookName ... - String. Required. Hook to source.

Debugging settings

Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:

  • hook - hookRun and hookSource and optional versions of the same functions will output additional debugging information

Examples

version="$(hookSource version-current)"

Return codes

  • Any - The hook exit code is returned if it is run
  • 1 - is returned if the hook is not found

Environment

See Also

hookRunOptional

Optionally run a project hook

Usage

hookRunOptional [ --next scriptName ] [ --application applicationHome ] [ --extensions extensionList ] hookName [ ... ] [ --help ]

Identical to hookRun but returns exit code zero if the hook does not exist.

Location: bin/build/tools/hook.sh

Arguments

  • --next scriptName - File. Optional. Run the script found after the named script, if any. Allows easy chaining of scripts.
  • --application applicationHome - Path. Optional. Directory of alternate application home.
  • --extensions extensionList - ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults to BUILD_HOOK_EXTENSIONS.
  • hookName - String. Required. Hook name to run.
  • ... - Arguments. Optional. Any arguments to the hook. See each hook implementation for details.
  • --help - Flag. Optional. Display this help.

Debugging settings

Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:

  • hook - hookRun and hookSource and optional versions of the same functions will output additional debugging information

Examples

version="$(hookRunOptional version-current)"

Return codes

  • Any - The hook exit code is returned if it is run
  • 1 - is returned if the hook is not found

Environment

See Also

hookSourceOptional

Identical to hookRun but returns exit code zero if the

Usage

hookSourceOptional [ --application applicationHome ] [ --extensions extensionList ] hookName ...

Identical to hookRun but returns exit code zero if the hook does not exist.

Location: bin/build/tools/hook.sh

Arguments

  • --application applicationHome - Path. Optional. Directory of alternate application home.
  • --extensions extensionList - ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults to BUILD_HOOK_EXTENSIONS.
  • hookName ... - String. Required. Hook to source (if it exists).

Debugging settings

Append to the value of BUILD_DEBUG (a comma-delimited (,) list) and add these tokens to enable debugging:

  • hook - hookRun and hookSource and optional versions of the same functions will output additional debugging information

Examples

hookSourceOptional test-cleanup

Return codes

  • Any - The hook exit code is returned if it is run
  • 0 - is returned if the hook is not found

Environment

See Also

hookFind

Find the path to a hook binary file

Usage

hookFind [ --application applicationHome ] [ --extensions extensionList ] [ --next scriptName ] hookName0 [ hookName1 ]

Does a hook exist in the local project?

Find the path to a hook. The search path is:

  • ./bin/hooks/
  • ./bin/build/hooks/

If a file named hookName with the extension .sh is found which is executable, it is output.

Location: bin/build/tools/hook.sh

Arguments

  • --application applicationHome - Path. Optional. Directory of alternate application home. Can be specified more than once to change state.
  • --extensions extensionList - ColonDelimitedList. Optional. List of extensions to search, in order for matching files in each hook directory. Defaults to BUILD_HOOK_EXTENSIONS.
  • --next scriptName - File. Optional. Locate the script found after the named script, if any. Allows easy chaining of scripts.
  • hookName0 - String. Required. Hook to locate
  • hookName1 - String. Optional. Additional hooks to locate.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

Environment

See Defined Hooks


🛠️ Tools · ⬅ Top