UNPKG

@augment-vir/node

Version:

A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.

11 lines (10 loc) 627 B
import { addSuffix } from '@augment-vir/common'; import { stat } from 'node:fs/promises'; import { runShellCommand } from '../../augments/terminal/shell.js'; export async function copyToContainer({ containerAbsolutePath, hostPath, containerNameOrId, dockerFlags = [], }) { const isDir = (await stat(hostPath)).isDirectory(); const suffix = isDir ? '/.' : ''; const fullHostPath = addSuffix({ value: hostPath, suffix }); const extraInputs = dockerFlags.join(' '); await runShellCommand(`docker cp ${extraInputs} '${fullHostPath}' '${containerNameOrId}:${containerAbsolutePath}'`, { rejectOnError: true }); }