Skip to content

Instantly share code, notes, and snippets.

@ededejr
Created May 19, 2024 23:45
Show Gist options
  • Save ededejr/b303f838d64f850f1ef7b8c3b126a973 to your computer and use it in GitHub Desktop.
Save ededejr/b303f838d64f850f1ef7b8c3b126a973 to your computer and use it in GitHub Desktop.
small nodejs sh wrapper
import { ExecSyncOptions, execSync } from 'child_process';
export function sh(command: TemplateStringsArray, ...substitutions: any[]) {
const fullCommand = command.reduce((acc, part, i) => acc + part + (substitutions[i] || ''), '');
return (options?: ExecSyncOptions) => execSync(fullCommand, { encoding: 'utf-8', ...(options || {}) });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment