Tasks
Task recipes always run when invoked. Use them for commands that should execute every time.
Basic Tasks
Section titled “Basic Tasks”task clean: rm -rf dist/ rm -rf node_modules/
task test: npm test
task dev: npm run devParameters
Section titled “Parameters”Tasks support parameters with optional default values:
task greet name="World": echo "Hello, {{name}}!"
task deploy env="staging" version="latest": echo "Deploying {{version}} to {{env}}" ./deploy.sh {{env}} {{version}}Using Parameters
Section titled “Using Parameters”$ jake greet name=AliceHello, Alice!
$ jake deploy env=production version=1.2.3Deploying 1.2.3 to productionDependencies
Section titled “Dependencies”Tasks can depend on other recipes:
task build: echo "Building..."
task test: [build] echo "Testing after build..."
task deploy: [build, test] echo "Deploying after build and test..."Positional Arguments
Section titled “Positional Arguments”Pass arguments directly using {{$1}}, {{$2}}, etc:
task greet: echo "Hello, {{$1}}!"$ jake greet WorldHello, World!All Arguments
Section titled “All Arguments”Access all arguments with {{$@}}:
task echo-all: echo "Arguments: {{$@}}"$ jake echo-all a b c dArguments: a b c dMetadata
Section titled “Metadata”Description
Section titled “Description”task deploy: @description "Deploy application to production server" ./deploy.shGrouping
Section titled “Grouping”@group buildtask build-frontend: npm run build
@group buildtask build-backend: cargo buildPlatform-Specific
Section titled “Platform-Specific”@only-os linux macostask install-deps: ./install.sh
@only-os windowstask install-deps: install.batValid OS values: linux, macos, windows
When to Use Tasks
Section titled “When to Use Tasks”Use task when:
- The command should run every time (tests, dev servers, deployments)
- You need parameters
- You want explicit, self-documenting syntax
Use file when:
- The recipe produces an output file
- You want incremental builds