Skip to content

Instantly share code, notes, and snippets.

@sndrs
Created March 7, 2019 14:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sndrs/f9d6284aca6262da16413d0d7b9faa06 to your computer and use it in GitHub Desktop.
Save sndrs/f9d6284aca6262da16413d0d7b9faa06 to your computer and use it in GitHub Desktop.
Check for – and use – NVM from a makefile
export PATH := node_modules/.bin:$(PATH)
export SHELL := /usr/bin/env bash
.PHONY: dev
dev: check-nvm install # run `yarn dev` in .nvmrc-mandated node
@bash -l -c 'nvm exec --silent yarn -s dev'
.PHONY: install
install: # install deps using yarn in .nvmrc-mandated node
@bash -l -c 'nvm exec --silent yarn -s'
.PHONY: check-nvm
check-nvm: # will error with link to install NVM if it's not installed
@bash -l -c 'type -t nvm > /dev/null || { echo -e "\x1b[31mYou need to install NVM:\x1b[0m https://github.com/creationix/nvm#installation-and-update"; exit 1; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment