Skip to content

Instantly share code, notes, and snippets.

@peterldowns
Last active March 29, 2024 15:48
Show Gist options
  • Save peterldowns/9256feea34b9ea84004b59dd874ee251 to your computer and use it in GitHub Desktop.
Save peterldowns/9256feea34b9ea84004b59dd874ee251 to your computer and use it in GitHub Desktop.
Script to generate a Makefile wrapper for a Justfile, with examples.
#!/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 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
.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