I can get a value from package.json
with this:
LAST_VERSION := $(shell node -p "require('./package.json').version")
But what if I need several values? Like:
PROJECT := $(shell node -p "require('./package.json').name")
LAST_VERSION:= $(shell node -p "require('./package.json').version")
DESCRIPTION := $(shell node -p "require('./package.json').description")
PROJECT_URL := $(shell node -p "require('./package.json').repository.url")
Is this the only way? Maybe there is a way to create kind of a list.
At the end, I came up with this:
define GetFromPkg
$(shell node -p "require('./package.json').$(1)")
endef
PROJECT := $(call GetFromPkg,name)
LAST_VERSION := $(call GetFromPkg,version)
DESCRIPTION := $(call GetFromPkg,description)
PROJECT_URL := $(call GetFromPkg,repository.url)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With