Skip to content

Directives

Placed at the top level of a Jakefile.

DirectiveDescription
@defaultMark next recipe as default
@dotenvLoad .env file
@dotenv "path"Load specific env file
@export VAR=valueExport environment variable
@require VAR...Require environment variables
@import "path"Import another Jakefile
@import "path" as nameImport with namespace
@pre commandGlobal pre-hook
@post commandGlobal post-hook
@before recipe commandPre-hook for specific recipe
@after recipe commandPost-hook for specific recipe
@on_error commandRun on any recipe failure

Placed before a recipe definition.

DirectiveDescription
@group nameGroup recipe in listings
@only-os os...Only run on specified OS
@quietSuppress command echoing

Used inside recipe bodies.

DirectiveDescription
@description "text"Recipe description
@pre commandRecipe pre-hook
@post commandRecipe post-hook
@confirm "message"Ask for confirmation
@needs cmd...Require commands exist
@needs cmd "hint"With installation hint
@needs cmd -> recipeWith auto-install recipe
@cd pathChange working directory
@shell nameUse different shell
@ignoreContinue on failure
@cache pattern...Skip if files unchanged
@watch pattern...Watch patterns for -w
DirectiveDescription
@if conditionConditional start
@elif conditionElse-if branch
@elseElse branch
@endEnd conditional/loop
@each items...Loop over items
PrefixDescription
@Suppress command echoing

Example:

task build:
@echo "Building quietly..."
npm run build

For use with @if:

FunctionDescription
env(VAR)Variable is set and non-empty
exists(path)File/directory exists
eq(a, b)Strings are equal
neq(a, b)Strings are not equal
is_watching()In watch mode
is_dry_run()In dry-run mode
is_verbose()In verbose mode