hammerkit
  • About
  • Installation
  • Getting started
  • Build file
    • Environment Variables
    • References
    • Includes
  • Task
    • Dependencies
    • Needs
    • Caching
    • Container
    • Watching
    • Extending
  • Service
    • Container
    • Kubernetes
  • Labels
  • CLI
    • Init
    • ls
    • Execute
    • Store / Restore
    • Clean
    • Validate
    • Help
  • External Links
    • Docker Hub
    • Homebrew Repository
  • Release Blog
    • Release 1.4.0
    • Release 1.5.0
  • Contribution
    • Roadmap
    • Publishing
Powered by GitBook
On this page
  • Extend a task
  • Override properties in an extend

Was this helpful?

  1. Task

Extending

A task can be used as a base template and extended. This is intended to reduce duplicate task definitions.

Extending tasks can save a lot of duplicated tasks in bigger projects and monorepos. With the task extend property a base configuration can be used as a template.

The following sections and examples use the two predefined tasks in thebuild.tsc.yaml file.

build.tsc.yaml
tasks:
  install:
    src:
      - package.json
      - package-lock.json
    generates:
      - node_modules
    cmds:
      - npm ci
      
  build:
    deps: [ install ]
    src:
      - tsconfig.json
      - src
    cmds:
      - node_modules/.bin/tsc
    generates:
      - dist

Extend a task

Extending the tsc:build task will use all defined properties as a base. If nothing else is defined, it will be an exact copy with the working directory of the current build file.

.hammerkit.yaml
tasks:
  build:
    extend: tsc:build
    
includes:
  tsc: ./build.tsc.yaml

Override properties in an extend

Every extended task can override defined or undefined properties. In this example the dependency gets cleared and runs without a dependency to the install task.

.hammerkit.yaml
tasks:
  build:
    extend: tsc:build
    deps: []
    
includes:
  tsc: ./build.tsc.yaml
PreviousWatchingNextService

Last updated 2 years ago

Was this helpful?