Last active
March 8, 2024 19:10
-
-
Save poyaz/75d60cd2e7217e55c4cbd249ae794318 to your computer and use it in GitHub Desktop.
Makefile for init nestjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NEST_PROJECT_DIR ?= $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) | |
| NEST_PROJECT_NAME ?= | |
| check_defined = \ | |
| $(strip $(foreach 1,$1, \ | |
| $(call __check_defined,$1,$(strip $(value 2))))) | |
| __check_defined = \ | |
| $(if $(value $1),, \ | |
| $(error Undefined $1$(if $2, ($2)))) | |
| .ONESHELL: | |
| .PHONY: install-nest | |
| install-nest: | |
| @:$(call check_defined, NEST_PROJECT_DIR, "The project dir is required") | |
| @:$(call check_defined, NEST_PROJECT_NAME, "The project name is required") | |
| docker run --rm -i -v $(NEST_PROJECT_DIR):/app -w /app -u $$(id -u ${USER}):$$(id -g ${USER}) node:20-alpine3.19 /bin/sh -s << EOF | |
| NPM_CONFIG_PREFIX=/tmp npm i -g @nestjs/cli | |
| /tmp/bin/nest new -p npm --directory . $(NEST_PROJECT_NAME) | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment