Makefile -> Taskfile

Makefile

I add a Makefile to every project I work with. I don't usually work on C/C++ projects or any other compiled languages but Makefile is good to make aliases for long commands.

Here is an example of short version of Makefile I use:

.PHONY: up
up:
    docker-compose up -d

.PHONY: logs
logs:
    tail -f ./storage/logs/*.log

There are set of aliases / mnemonics that I used to:

Since I work with multiple languages and frameworks, thanks to this approach, I don't need to remember how to start a project, how to compile JS files, how to read logs, etc... All those commands are hidden under make targets.

On the other hand Makefiles aren't designed for such use. make is super powerful tool and using it as an alias system just feels wrong.

Taskfile

Taskfile - is just a shell script where you can define functions to call.

function up {
    podman-compose up -d --build
}

function down {
    podman-compose down
}

function npm {
    podman run -it -v `pwd`:/app -w /app node:latest npm $@
}

function composer {
    podman-compose exec app composer $@
}

TIMEFORMAT="Task completed in %3lR"
time ${@:-default}

Place this file in your project root, make it executable and you can call those aliases with ./Taskfile up or ./Taskfile composer install.

To simplify this a bit add this line to you bashrc/zshrc:

alias run=./Taskfile

Now you can call all those commands as run up or run composer install. Pretty handy.

This idea was borrowed from

=> Adrian Cooney

and his

=> Taskfile repo

.

Proxy Information
Original URL
gemini://g.codelearn.me/2022-04-16-makefile-taskfile.gmi
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
444.697411 milliseconds
Gemini-to-HTML Time
0.61963 milliseconds

This content has been proxied by September (ba2dc).