UNPKG

@enspirit/emb

Version:

A replacement for our Makefile-for-monorepos

37 lines (36 loc) 1.06 kB
import { execa } from 'execa'; import * as z from 'zod'; import { AbstractOperation } from '../../../operations/index.js'; /** * https://docs.docker.com/reference/api/engine/version/v1.37/#tag/Exec/operation/ContainerExec */ const schema = z.object({ env: z .record(z.string(), z.string()) .optional() .describe('A list of environment variables in the form'), script: z.string().describe('Command to run, as a string'), workingDir: z .string() .optional() .describe('The working directory for the exec process inside the container'), }); export class ExecuteLocalCommandOperation extends AbstractOperation { out; constructor(out) { super(schema); this.out = out; } async _run(input) { const process = execa(input.script, { all: true, cwd: input.workingDir, shell: true, env: input.env, }); if (this.out) { process.all.pipe(this.out); } return process.all; } }