A tiny, type-safe wrapper for executing shell commands in Deno with flexible output handling.
- Simple API – One function, full power
- Normal & Stream modes – Capture output or stream live to terminal
- Custom
variantshortcut – Set bothstdout/stderrat once - TypeScript-first – Full types, zero runtime surprises
- Zero dependencies – Lightweight, fast, pure Deno
- Deno:
Then import as an ES module:
deno add jsr:@dep/exec
import { exec } from '@dep/exec';
import { exec } from '@dep/exec';
const { stdout, stderr, code } = await exec('git', {
args: ['status', '--short'],
});
console.log('Exit code:', code);
console.log('Output:', stdout); // string or null
console.log('Errors:', stderr); // string or nullawait exec('ls', {
args: ['-la'],
stdout: 'inherit',
stderr: 'inherit',
});// Stream both stdout & stderr
await exec('npm', { args: ['run', 'build'], variant: 'inherit' });
// Capture only stdout, discard stderr
const { stdout } = await exec('deno', {
args: ['--version'],
variant: 'piped',
stderr: 'null',
});await exec('echo', {
args: ['Hello'],
cwd: '/tmp',
env: { DEBUG: '1' },
stdout: 'piped',
stderr: 'null',
});interface ExecResult {
code: number;
stdout: string | null;
stderr: string | null;
}interface ExecOptions extends Deno.CommandOptions {
variant?: 'piped' | 'inherit' | 'null';
}MIT License – see LICENSE for details.
Author: Estarlin R (estarlincito.com)