8000 Cross-platform `sh` via `deno` or `busybox` · Issue #2671 · casey/just · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Cross-platform sh via deno or busybox #2671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cspotcode opened this issue Mar 20, 2025 · 3 comments
Open

Cross-platform sh via deno or busybox #2671

cspotcode opened this issue Mar 20, 2025 · 3 comments

Comments

@cspotcode
Copy link

I wanted to quickly share an option for writing cross-platform justfiles using (limited) sh-style syntax: leverage deno's task subcommand.

Context

I'm an OSS maintainer, projects support Windows, I want to use justfiles, I must make it extremely easy for potential contributors to install all necessary dependencies that are outside of the language ecosystem's core tools. For example, Golang devs obviously have golang installed, but they shouldn't be expected to jump through hoops to install shells and command runners.

Setup

Tell just to use deno's sh interpreter subcommand, deno task.

set shell := ["deno", "task", "--quiet", "--eval"]

# Sample recipe
prune-docs:
    cat *.md | markdown-formatter-tool dist/docs.md

PowerShell can't do this, because PowerShell's cat is subtly different -- breaks newlines, breaks binary files -- and PowerShell doesn't do * globbing.

Deno handles it correctly.

Installation

For contributors on Windows:

winget install -e --id Casey.Just
winget install -e --id DenoLand.Deno

Why deno?

"Isn't deno a JavaScript/TypeScript thing? I hate JavaScript/TypeScript! My project is C#/golang/rust/etc!"

In this case, we are using deno's built-in ability to run one-line commands written in sh-style syntax, exactly what just needs for vanilla recipes!
We are not running any JavaScript.

https://docs.deno.com/runtime/reference/cli/task/#syntax

Deno installs as a single, ~100MB binary file.

@cspotcode
Copy link
Author
cspotcode commented Mar 20, 2025

Immediately after posting this, I remembered to search winget for busybox. I feel a bit silly because, sure enough, there it is:

winget install -e --id frippery.busybox-w32

The great thing about busybox is that it bakes-in the standard suite of unix tools which are often shipped as external binaries -- cat, echo, rm, awk, etc. And it's a single, 1/2MB binary.

Setup like so:

set windows-shell := ["busybox", "sh", "-eu", "-c"]
set script-interpreter := if os() == "windows" { ["busybox", "sh", "-eu"] } else { ["sh", "-eu"] } # This conditional syntax is not supported; how to do it??

@cspotcode cspotcode changed the title Cross-platform sh via deno Cross-platform sh via deno or busybox Mar 20, 2025
@casey
Copy link
Owner
casey commented Mar 20, 2025

Good find! I think that's something that could probably be added to the readme, assuming that there are no gotchas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0