From 433c5013e85291a19b8618e0e9be4c8bcf65f3f6 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Wed, 13 Jul 2016 15:04:11 -0700 Subject: [PATCH] update makefile --- Makefile | 67 +++++++++++++--------------------------------------- package.json | 1 + 2 files changed, 18 insertions(+), 50 deletions(-) diff --git a/Makefile b/Makefile index ccefa3dbf..58443e3e3 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,12 @@ mocha-phantomjs = $(bin)/mocha-phantomjs node = node watchify = $(bin)/watchify +# Options. +babel_flags = +browserify_flags = --debug --transform babelify +eslint_flags = --ignore-pattern "build.js" +mocha_flags = --compilers js:babel-core/register --require source-map-support/register --reporter spec + # Flags. DEBUG ?= GREP ?= @@ -29,19 +35,12 @@ clean: @ rm -rf ./dist ./node_modules # Build the source. -dist: $(shell find ./lib) package.json - @ $(babel) \ - --out-dir \ - ./dist \ - ./lib +dist: $(shell find ./lib) package.json + @ $(babel) $(babel_flags) --out-dir ./dist ./lib # Build the examples. examples: - @ $(browserify) \ - ./examples/index.js \ - --debug \ - --transform babelify \ - | $(exorcist) ./examples/build.js.map > ./examples/build.js + @ $(browserify) $(browserify_flags) ./examples/index.js --outfile ./examples/build.js # Install the dependencies. install: @@ -49,55 +48,23 @@ install: # Lint the source files. lint: - @ $(eslint) \ - "lib/**/*.js" \ - "examples/**/*.js" --ignore-pattern "build.js" + @ $(eslint) $(eslint_flags) "lib/**/*.js" "examples/**/*.js" -# Start the examples server. -start-examples: +# Start the server. +start: @ $(http-server) ./examples -# Build the test source. -test/support/build.js: $(shell find ./lib) ./test/browser.js - @ $(browserify) \ - ./test/browser.js \ - --debug \ - --transform babelify \ - --outfile ./test/support/build.js - # Run the tests. -test: test-server - -# Run the browser-side tests. -test-browser: ./test/support/build.js - @ $(mocha-phantomjs) \ - --reporter spec \ - ./test/support/browser.html - -# Run the server-side tests. -test-server: - @ $(mocha) \ - --compilers js:babel-core/register \ - --require source-map-support/register \ - --reporter spec \ - --fgrep "$(GREP)" \ - ./test/server.js +test: + @ $(mocha) $(mocha_flags) --fgrep "$(GREP)" ./test/server.js # Watch the source. -watch-dist: $(shell find ./lib) package.json - @ $(babel) \ - --watch \ - --out-dir \ - ./dist \ - ./lib +watch-dist: + @ $(MAKE) dist babel_flags="$(babel_flags) --watch" # Watch the examples. watch-examples: - @ $(watchify) \ - ./examples/index.js \ - --debug \ - --transform babelify \ - --outfile "$(exorcist) ./examples/build.js.map > ./examples/build.js" + @ $(MAKE) examples browserify=$(watchify) # Phony targets. .PHONY: examples diff --git a/package.json b/package.json index 2cb9cd68b..275704d08 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "main": "./dist/index.js", "scripts": { "prepublish": "make dist", + "start": "make start", "test": "make check" }, "dependencies": {