Skip to content

Instantly share code, notes, and snippets.

@aslakhellesoy
Created December 20, 2011 09:43
Show Gist options
  • Save aslakhellesoy/1500978 to your computer and use it in GitHub Desktop.
Save aslakhellesoy/1500978 to your computer and use it in GitHub Desktop.
Fetch NPM modules with Make
node_modules: Makefile
@rm -rf $@
@mkdir -p $@
$(call get_src_module,$@,https://github.com/tastapod/node-imap/tarball/bruno-merge)
$(call get_npm_module,$@,log,1.2.0)
$(call get_npm_module,$@,connect,1.8.2)
# We have to manually fetch connect's dependencies
$(call get_npm_module,$@,qs,0.4.0)
$(call get_npm_module,$@,mime,1.2.4)
$(call get_npm_module,$@,formidable,1.0.8)
@touch $@
# Grab Node module from NPM repository.
# Args : destination dir, module name, version
# Example : $(call get_npm_module,node_modules,websocket,1.0.1)
get_npm_module = $(call get_node_module,$1,$2,http://registry.npmjs.org/$2/-/$2-$3.tgz,package)
# Grab Node module from source tarball.
# Args : destination dir, module name, url
# Example : $(call get_src_module,$@,imap,https://github.com/tastapod/node-imap/tarball/bruno-merge)
get_src_module = $(call get_node_module,$1,$2,$3,)
# Supports above functions
get_node_module = @set -e; mkdir -p $1/$2; echo "Fetching module $2 <$3>"; curl -L --silent $3 | tar xzf - --strip=1 --directory=$1/$2 $4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment