@hongminhee@hollo.social

When I need TypeScript to behave like a shell script, I reach for dax. It started Deno-only, but now works on Node.js too.

Instead of calling node:child_process or writing a .sh file, you write commands in a tagged template literal:

const branch = await $`git rev-parse --abbrev-ref HEAD`.text();
await $`echo "Deploying ${branch}"`;
await $`deno task build && deno task deploy`;

I can still write the shell syntax I reach for most: &&, ||, pipes, redirects, and subshells. It uses deno_task_shell, so the same script can run on Windows without rewriting anything.

Interpolations are escaped automatically. $`mkdir ${dir}` stays safe even if dir contains spaces or quotes. Output parsing lives on the command itself: .text(), .json(), .lines().

I've been reaching for it whenever a .sh script starts breaking on Windows. For my scripts, it's usually been close to a drop-in.

github.com

GitHub - denoland/deno_task_shell: Cross-platform shell for deno task.

Cross-platform shell for deno task. Contribute to denoland/deno_task_shell development by creating an account on GitHub.