Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Latest commit

 

History

History
executable file
·
100 lines (75 loc) · 1.83 KB

File metadata and controls

executable file
·
100 lines (75 loc) · 1.83 KB

🏠 > 🧠 Core Concepts > 🔨 Task

🍲 Define task dependencies

Some tasks might require several pre-requisites.

For example, a typescript developer needs to install npm packages and compile their typescript before running/testing their application.

To start a typescript application, you need to do:

# prepare app
npm install
tsc
# start app
npm start

while to test the application, you need to do:

# prepate app
npm install
tsc
# test app
npm test

You can make a zaruba script to execute those actions:

tasks:

  prepareApp:
    extend: zrbRunShellScript
    configs:
      start: npm install && tsc

  startApp:
    extend: zrbStartApp
    dependencies:
      - prepareApp
    configs:
      ports: 3000
      start: npm start

  testApp:
    extend: zrbRunShellScript
    dependencies:
      - prepareApp
    configs:
      start: npm test

The scripts has some advantages:

  • You can update prepareApp without touching startApp and testApp.
  • In case of you have many dependencies, Zaruba will run the dependencies in parallel.

Let's modify the script a little bit to run startApp and testApp in parallel:

tasks:

  prepareApp:
    extend: zrbRunShellScript
    configs:
      start: npm install && tsc

  startApp:
    extend: zrbStartApp
    dependencies:
      - prepareApp
    configs:
      ports: 3000
      start: npm start

  testApp:
    extend: zrbRunShellScript
    dependencies:
      - prepareApp
    configs:
      start: npm test

  startAndTestApp:
    dependencies:
      - startApp
      - testApp

Cool. Now, whenever you run zaruba please startAndTestApp, things will be executed in this order: