Skip to content

Tasks

Tasks are scripts you can run across your monorepo. They can be defined at the project level (in .emb.yml) or at the component level (in Embfile.yml).

View all available tasks:

Terminal window
emb tasks
NAME COMPONENT DESCRIPTION ID
----------------------------------------------------------------
build Build the entire project build
deps Install project dependencies deps
setup Set up the development environment setup
fail api A task that will fail api:fail
lint api Run linter on API code api:lint
test api Run API tests api:test
test web Run frontend tests web:test

Tasks without a component are project-level tasks. Tasks with a component (like api:test) are component-specific.

Defined in .emb.yml, these run in the project root context:

tasks:
setup:
description: Set up the development environment
script: |
echo "Setting up $ENV environment"

Run with:

Terminal window
emb run setup

Defined in a component’s Embfile.yml:

api/Embfile.yml
tasks:
test:
description: Run API tests
script: npm test

Run with the full task ID:

Terminal window
emb run api:test

Tasks can define their own variables:

tasks:
setup:
vars:
ENV: ${env:NODE_ENV:-development}
script: |
echo "Setting up $ENV environment"

The vars section defines variables available to the script. They can reference environment variables with defaults.

Tasks can depend on other tasks:

tasks:
deps:
description: Install project dependencies
script: |
echo "Installing dependencies..."
build:
description: Build the entire project
pre: ['deps']
script: |
echo "Building project..."

When you run emb run build, EMB automatically runs deps first.

Run a project-level task:

Terminal window
emb run setup

This outputs:

Setting up development environment

Run a component task:

Terminal window
emb run api:test

By default, task output is displayed in real-time. Task logs are also saved to .emb/default/logs/tasks/.

If a task fails, EMB reports the error:

Terminal window
emb run api:fail

This would exit with a non-zero code, useful for CI/CD pipelines.

Continue to Docker Compose to learn about running multi-service applications.