Skip to content

Commit

Permalink
Makefile now builds changed files in lib
Browse files Browse the repository at this point in the history
I'm sure there was a better way to do this, but while developing,
I was doing something like:

$ rm -rf node && make && bin/slackin

Well, that's a bit unnecessary, since make is smart enough to
dynamically build sources into targets, so this commit cleans up
the make file to do just that. Now changing a file in lib/ and
running make will do the right thing to put it in node/.
  • Loading branch information
James Tatum committed Jul 24, 2015
1 parent 216bd0a commit a9da5d8
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
INJS = $(wildcard lib/*.js)
OUTJS = $(subst lib/,node/,$(INJS))

INASSETS = $(wildcard lib/assets/*)
OUTASSETS = $(subst lib/assets/,node/assets/,$(INASSETS))

BABEL = ./node_modules/.bin/babel

all: node
.PHONY: clean

all: node/assets $(OUTJS) $(OUTASSETS)

clean:
rm -rf node/

node/assets/% : lib/assets/%
cp $^ $@

node/%.js: lib/%.js
$(BABEL) $^ > $@

node: lib
@mkdir -p node/assets/
@rm -rf node/assets/*
@cp -r lib/assets node/
@for path in lib/*.js; do \
file=`basename $$path`; \
$(BABEL) "lib/$$file" > "node/$$file"; \
done
node/assets:
mkdir -p node/assets/

0 comments on commit a9da5d8

Please sign in to comment.