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).
Listing Tasks
Section titled “Listing Tasks”View all available tasks:
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:testTasks without a component are project-level tasks. Tasks with a component (like api:test) are component-specific.
Project-Level Tasks
Section titled “Project-Level Tasks”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:
emb run setupComponent Tasks
Section titled “Component Tasks”Defined in a component’s Embfile.yml:
tasks: test: description: Run API tests script: npm testRun with the full task ID:
emb run api:testTask Variables
Section titled “Task Variables”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.
Task Prerequisites
Section titled “Task Prerequisites”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.
Running Tasks
Section titled “Running Tasks”Run a project-level task:
emb run setupThis outputs:
Setting up development environmentRun a component task:
emb run api:testTask Output
Section titled “Task Output”By default, task output is displayed in real-time. Task logs are also saved to .emb/default/logs/tasks/.
Handling Failures
Section titled “Handling Failures”If a task fails, EMB reports the error:
emb run api:failThis would exit with a non-zero code, useful for CI/CD pipelines.
Next Step
Section titled “Next Step”Continue to Docker Compose to learn about running multi-service applications.