@augment-vir/node
Version:
A collection of augments, helpers types, functions, and classes only for Node.js (backend) JavaScript environments.
15 lines (14 loc) • 454 B
JavaScript
import { killContainer } from './kill-container.js';
/**
* Runs a callback (which presumably runs a command within the given `containerName`) and kills the
* given `containerName` container if the callback fails.
*/
export async function tryOrKillContainer(containerNameOrId, callback) {
try {
return await callback(containerNameOrId);
}
catch (error) {
await killContainer(containerNameOrId);
throw error;
}
}