Skip to content

Commit

Permalink
2024-08-13/01: update Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagokokada committed Aug 14, 2024
1 parent e2c30dc commit 62eee94
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions 2024-08-13/01-abusing-makefiles-for-fun-and-profit.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ responsible to do some transformations in the Markdown files before posting.

While I could manage everything by just using `go` CLI and a few other *nix
commands, to make it easier to manager everything I have the following
[`Makefile`](https://github.com/thiagokokada/blog/blob/5a4377648161ceb9ffa8297bcec97b58a5650b21/Makefile):
[`Makefile`](https://github.com/thiagokokada/blog/blob/e2c30dcc117ba0b95e3df1dbea0be6b5064d5a7e/Makefile):

```Makefile
MARKDOWN := $(shell find . -type f -name '*.md' -not -name README.md)
MARKDOWN := $(wildcard ./**/*.md)

.PHONY: all
all: README.md rss.xml
Expand All @@ -119,20 +119,19 @@ _PARSED_DAY := $(shell date '+%Y-%m-%d' -d '$(DAY)')
day:
mkdir -p '$(_PARSED_DAY)'

TITLE = $(error TITLE is not defined)
.PHONY: post
post: blog day
@[ "${TITLE}" ] || ( echo ">> TITLE is not set"; exit 1 )
./.scripts/gen-post.sh '$(_PARSED_DAY)' '$(TITLE)'

TITLE = $(error FILE is not defined)
.PHONY: draft
draft:
@[ "${FILE}" ] || ( echo ">> FILE is not set"; exit 1 )
mv '$(FILE)' '$(dir $(FILE)).$(notdir $(FILE))'
cd '$(dir $(FILE))' && mv '$(notdir $(FILE))' '.$(notdir $(FILE))'

.PHONY: undraft
undraft:
@[ "${FILE}" ] || ( echo ">> FILE is not set"; exit 1 )
mv '$(FILE)' '$(dir $(FILE))$(patsubst .%,%,$(notdir $(FILE)))'
cd '$(dir $(FILE))' && mv '$(notdir $(FILE))' '$(patsubst .%,%,$(notdir $(FILE)))'

.PHONY: clean
clean:
Expand Down

0 comments on commit 62eee94

Please sign in to comment.