3
\$\begingroup\$

I've got the following Makefile:

.PHONY: install install-prod clean
MODULE := ./node_modules/.bin
COMPOSE := docker-compose -f docker-compose.yml
install:
 @echo "--- Installing dependencies!"
 npm install
install-prod:
 @echo "--- Installing production dependencies!"
 npm install --only=production
build:
 @echo "--- Babelify-ing code!"
 npm run build
run:
 @echo "--- Building Docker and running app!"
 ${COMPOSE} up --build -d app
test:
 @echo "--- Running tests"
 npm run test
coverall:
 @echo "--- Running tests & reporting to Coverall!"
 npm run coverall
clear:
 @echo "--- Clearing everything!"
 ${COMPOSE} down

It's a simple one, but in essence, it wraps commands in a package.json and a docker-compose.yml for an express app so it makes calls in a CI Pipeline easier to understand and maintain.

I would love some feedback about whether it can be optimized, cleaner, or potentially smaller. Anything really.

toolic
14.7k5 gold badges29 silver badges204 bronze badges
asked Oct 24, 2017 at 6:34
\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

It is good that you specify a .PHONY target. For consistency, it is a good practice to add all of the targets to the .PHONY list since none of them refers to a file. For example, like the install target does not create a file named install, the build target does not create a file named build. This means build should be added to the .PHONY list along with install.

Since the Makefile does not use the MODULE variable, you can delete the line:

MODULE := ./node_modules/.bin
answered Apr 17, 2024 at 11:14
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.