Skip to content

Commit 3f11c8a

Browse files
committed
feat: add clean target to Makefile for removing local branches and build artifacts
1 parent 8b758ed commit 3f11c8a

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Makefile

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: install lint test build update drawio
1+
.PHONY: install lint test build update drawio clean
22
DEFAULT_GOAL := build
33

44
install:
@@ -35,3 +35,21 @@ drawio:
3535
exit 1; \
3636
fi; \
3737
"$$DRAWIO_CMD" -x -o docs/assets --transparent -f png docs/assets/drawio/*.drawio
38+
39+
clean:
40+
@git fetch --prune
41+
@git branch -vv | awk '/: gone]/{print $$1}' > .git/branches-to-delete || true
42+
@if [ -s .git/branches-to-delete ]; then \
43+
echo "---" ; cat .git/branches-to-delete ; \
44+
while read b; do \
45+
if [ "$$b" != "$(shell git rev-parse --abbrev-ref HEAD)" ]; then \
46+
git branch -D $$b || true; \
47+
else \
48+
echo "Skipping current branch: $$b"; \
49+
fi; \
50+
done < .git/branches-to-delete; \
51+
else \
52+
echo "No local branches to delete"; \
53+
fi;
54+
@rm -Rf .git/branches-to-delete || true
55+
@rm -Rf dist node_modules coverage || true

0 commit comments

Comments
 (0)