Skip to content

Instantly share code, notes, and snippets.

@Duologic
Created April 24, 2016 15:40
Show Gist options
  • Save Duologic/cd760a2c7609c840c9d49596a5dea101 to your computer and use it in GitHub Desktop.
Save Duologic/cd760a2c7609c840c9d49596a5dea101 to your computer and use it in GitHub Desktop.
Makefile example with NPM and gulp
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
NPM_ROOT ?= ${ROOT_DIR}/npm
NODE_PATH := ${NPM_ROOT}/node_modules
NODE_BIN_PATH := ${NODE_PATH}/.bin
.PHONY: install_npm_packages
install_npm_packages: ## Installs NPMv2 and runs npm install
@ echo "# Install latest static build packages"
mkdir -p ${NPM_ROOT}
cd ${NPM_ROOT} && test -e package.json || ln -s ${ROOT_DIR}/package.json
cd ${NPM_ROOT} && npm install npm@latest-2 --prefix ${NPM_ROOT}
cd ${NPM_ROOT} && ${NODE_BIN_PATH}/npm install --prefix ${NPM_ROOT}
.PHONY: gulp
gulp: ## Run a command with Gulp (ex. make gulp <argument>)
NODE_PATH=${NODE_PATH} ${NODE_BIN_PATH}/gulp --outputDirectory=${BUILD_ROOT} --libDirectory=${VENV_PATH} ${RUN_ARGS}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment