Skip to content

Instantly share code, notes, and snippets.

@jrstrunk
Last active February 28, 2025 12:24
Show Gist options
  • Save jrstrunk/0b949297e969f13343550e5f03109fc9 to your computer and use it in GitHub Desktop.
Save jrstrunk/0b949297e969f13343550e5f03109fc9 to your computer and use it in GitHub Desktop.
A makefile to make working with Gleam monorepos easier!
# List all subdirectories
SUBDIRS := $(wildcard */)
.PHONY: all
all:
@echo "Available commands: run, dev, test, update, format, build, add <package>, and remove <package>"
# Customize this per project
.PHONY: run
run:
@(cd client \
&& gleam run -m lustre/dev build component my_project/client/component --outdir="../server/priv/static" \
&& cd ../server \
&& gleam run)
# Customize this per project
.PHONY: dev
dev:
@(cd client && gleam run -m lustre/dev start)
.PHONY: test
test:
@for dir in $(SUBDIRS); do \
(cd $$dir && gleam test); \
done
.PHONY: update
update:
@for dir in $(SUBDIRS); do \
(cd $$dir && gleam update); \
done
.PHONY: format
format:
@for dir in $(SUBDIRS); do \
(cd $$dir && gleam format); \
done
.PHONY: build
build:
@for dir in $(SUBDIRS); do \
(cd $$dir && gleam build); \
done
.PHONY: add
add:
@for dir in $(SUBDIRS); do \
(cd $$dir && gleam add $(word 2,$(MAKECMDGOALS))); \
done
.PHONY: remove
remove:
@for dir in $(SUBDIRS); do \
(cd $$dir && gleam remove $(word 2,$(MAKECMDGOALS))); \
done
# This stops make from complaining that a package name is not a target after
# running `make add <package>` or `make remove <package>`
%:
@:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment