Skip to content
/ exec Public

A tiny, type-safe wrapper for executing shell commands in Deno with flexible output handling.

License

Notifications You must be signed in to change notification settings

dep-ts/exec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@dep/exec 🚀

A tiny, type-safe wrapper for executing shell commands in Deno with flexible output handling.

JSR version

Features ✨

  • Simple API – One function, full power
  • Normal & Stream modes – Capture output or stream live to terminal
  • Custom variant shortcut – Set both stdout/stderr at once
  • TypeScript-first – Full types, zero runtime surprises
  • Zero dependencies – Lightweight, fast, pure Deno

Installation 📦

  • Deno:
    deno add jsr:@dep/exec
    Then import as an ES module:
    import { exec } from '@dep/exec';

Usage 🎯

API 🧩

Normal Mode (default) – Capture output

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 null

Stream Mode – Live terminal output

await exec('ls', {
  args: ['-la'],
  stdout: 'inherit',
  stderr: 'inherit',
});

Using variant shortcut

// 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',
});

Full control with Deno.CommandOptions

await exec('echo', {
  args: ['Hello'],
  cwd: '/tmp',
  env: { DEBUG: '1' },
  stdout: 'piped',
  stderr: 'null',
});

Result type

interface ExecResult {
  code: number;
  stdout: string | null;
  stderr: string | null;
}

Options type

interface ExecOptions extends Deno.CommandOptions {
  variant?: 'piped' | 'inherit' | 'null';
}

License 📄

MIT License – see LICENSE for details.

Author: Estarlin R (estarlincito.com)

About

A tiny, type-safe wrapper for executing shell commands in Deno with flexible output handling.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published