UNPKG

@enspirit/emb

Version:

A replacement for our Makefile-for-monorepos

22 lines (21 loc) 872 B
import { getContext } from '../../../index.js'; import { ListContainersOperation } from '../../../docker/index.js'; import { Component } from '../../index.js'; export class GetComponentContainerOperation { async run(component) { const { monorepo } = getContext(); const cmpName = component instanceof Component ? component.name : component; const matching = await monorepo.run(new ListContainersOperation(), { filters: { label: [`emb/project=${monorepo.name}`, `emb/component=${cmpName}`], }, }); if (matching.length === 0) { throw new Error(`Could not find a running container for '${cmpName}'`); } if (matching.length > 1) { throw new Error(`More than one running container found for '${cmpName}'`); } return matching[0]; } }