Skip to content

Instantly share code, notes, and snippets.

@oaleynik
Forked from andreypopp/gist:5588256
Created December 17, 2014 17:09
Show Gist options
  • Save oaleynik/1f7815b8323f51c017da to your computer and use it in GitHub Desktop.
Save oaleynik/1f7815b8323f51c017da to your computer and use it in GitHub Desktop.
Sample Makefile
BIN = ./node_modules/.bin
SRC = $(wildcard src/*.coffee)
LIB = $(SRC:src/%.coffee=lib/%.js)
build: $(LIB)
lib/%.js: src/%.coffee
@mkdir -p $(@D)
@$(BIN)/coffee -bcp $< > $@
test: build
@$(BIN)/mocha -b specs
clean:
@rm -f $(LIB)
install link:
@npm $@
define release
VERSION=`node -pe "require('./package.json').version"` && \
NEXT_VERSION=`node -pe "require('semver').inc(\"$$VERSION\", '$(1)')"` && \
node -e "\
var j = require('./package.json');\
j.version = \"$$NEXT_VERSION\";\
var s = JSON.stringify(j, null, 2);\
require('fs').writeFileSync('./package.json', s);" && \
git commit -m "release $$NEXT_VERSION" -- package.json && \
git tag "$$NEXT_VERSION" -m "release $$NEXT_VERSION"
endef
release-patch: build test
@$(call release,patch)
release-minor: build test
@$(call release,minor)
release-major: build test
@$(call release,major)
publish:
git push --tags origin HEAD:master
npm publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment