central-script Sometimes people use a Makefile (Make ) just to have a list of shortcuts for frequently used commands. For example:
Makefile .PHONY : prepare lint build -docker
prepare :
sudo apt-get update
sudo apt-get install -y docker.io
lint :
npx prettier -c .
build-docker : lint
docker build -t $( imgname) .
I know that Make can do a lot more than that, but sometimes, for simple scenarios, this is enough. If this is the case, in my opinion there's no reason to use Make at all: we can do pretty much the same with a simple Bash script like the following:
Bash #!/bin/bash
set -e
cd " $( dirname " $0 " ) "
target_prepare() { sudo apt-get update; sudo apt-get install -y docker.io; }
target_lint() { npx prettier -c .; }
target_build_docker() { target_lint; docker build -t " $1 " .; }
while IFS = read -r i || [ -n " $i " ] ; do "target_ $i " " ${ @: 2 } "
done < <( printf '%s\n' " $1 " | tr , '\n' )
Then we can save it in the root of our project and invoke it like this:
Bash bash central.sh prepare,build-docker myimage