@segment/load-script
Version:
Dynamically and asynchronously load a script file.
78 lines (61 loc) • 1.48 kB
Plain Text
##
# Binaries
##
DEPCHECK := node_modules/.bin/npm-check
ESLINT := node_modules/.bin/eslint
KARMA := node_modules/.bin/karma
##
# Files
##
LIBS = index.js
SUPPORT = $(wildcard karma.conf*.js)
TESTS = $(shell find test -type f -name "*.js")
ALL_FILES = $(LIBS) $(TESTS) $(SUPPORT)
##
# Program options/flags
##
# A list of options to pass to Karma
# Overriding this overwrites all options specified in this file (e.g. BROWSERS)
KARMA_FLAGS ?=
# A list of Karma browser launchers to run
# http://karma-runner.github.io/0.13/config/browsers.html
BROWSERS ?=
ifdef BROWSERS
KARMA_FLAGS += --browsers $(BROWSERS)
endif
##
# Tasks
##
# Install node modules.
node_modules: package.json $(wildcard node_modules/*/package.json)
@npm install
@touch $@
# Install dependencies.
install: node_modules
# Remove temporary files and build artifacts.
clean:
rm -rf *.log coverage
# Remove temporary files, build artifacts, and vendor dependencies.
distclean: clean
rm -rf node_modules
# Check for stale or missing dependencies.
check-dependencies:
@$(DEPCHECK) --production --no-color --no-emoji
@echo
# Lint JavaScript source files.
lint: install
@$(ESLINT) $(ALL_FILES)
# Attempt to fix linting errors.
fmt: install
@$(ESLINT) --fix $(ALL_FILES)
# Run unit tests.
test-unit: install
@$(KARMA) start $(KARMA_FLAGS)
# Default test target.
test: lint check-dependencies test-unit
.DEFAULT_GOAL = test