Last active
March 29, 2024 15:48
-
-
Save peterldowns/9256feea34b9ea84004b59dd874ee251 to your computer and use it in GitHub Desktop.
Script to generate a Makefile wrapper for a Justfile, with examples.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Create a wrapper Makefile that allows people to run `make <foo>` | |
# instead of `just <foo>` in case their muscle-memory hasn't updated | |
# yet. | |
# | |
# Usage (from inside directory with a Justfile): | |
# | |
# generate-makefile.sh > Makefile | |
# | |
# | |
targets=($(just --unsorted --summary)) | |
cat <<EOF | |
.PHONY: ${targets[@]} | |
# This Makefile is a wrapper around the Justfile in this directory. | |
EOF | |
for target in "${targets[@]}"; do | |
cat <<EOF | |
$target: | |
just $target | |
EOF | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this setting will allow passing arguments through to tasks, see the docs here | |
# https://just.systems/man/en/chapter_24.html#positional-arguments | |
set positional-arguments | |
# print all available commands by default | |
default: | |
just --list | |
# run the test suite | |
test *args='./...': | |
go test "$@" | |
# lint the entire codebase | |
lint *args: | |
golangci-lint run --fix --config .golangci.yaml "$@" | |
# build bin/nix-search | |
build: | |
go build -o bin/nix-search ./cmd/nix-search |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: default test lint build | |
# This Makefile is a wrapper around the Justfile in this directory. | |
default: | |
just default | |
test: | |
just test | |
lint: | |
just lint | |
build: | |
just build | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment