Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created August 29, 2016 01:59
Show Gist options
  • Save ELLIOTTCABLE/79c2dbbcd8eb3f302ef92b6586d2f2f3 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/79c2dbbcd8eb3f302ef92b6586d2f2f3 to your computer and use it in GitHub Desktop.
{ "author" : "ELLIOTTCABLE (http://ell.io/tt)"
, "name" : "giraphe"
, "version" : "0.0.1"
, "license" : "ISC"
, "description": "A generic graph walking API."
, "repository" : "ELLIOTTCABLE/giraphe"
, "main" : "./giraphe.js"
, "scripts": {
"test" : "./test.sh"
, "build" : "./build.sh"
}
, "directories": {
"lib" : "./"
, "src" : "./"
, "test" : "./Tests"
, "doc" : "./Docs"
, "coverage" : "./Docs/Coverage"
}
, "babel": {
"presets" : ["es2015", "stage-2"]
, "plugins" : ["transform-runtime", "transform-flow-comments"]
, "sourceMaps" : "inline"
, "compact" : false
, "env": {
"coverage": {
"plugins": [ "istanbul" ]
}
, "development": {
"plugins": [ "babel-plugin-espower" ]
}
, "production": {
"plugins": [ "babel-plugin-unassert" ]
}
}
}
, "nyc": {
"all" : true
, "include" : ["giraphe.es6.js", "walk.es6.js.mustache"]
, "extension" : [".es6.js", ".es6.js.mustache"]
, "require" : ["babel-register"]
, "sourceMap" : false
, "instrument" : false
}
, "mocha": {
"ui" : "bdd"
, "reporter" : "mocha-fivemat-reporter"
}
, "dependencies": {
"debug" : "^2.2.0"
, "lodash" : "^4.13.1"
, "babel-runtime" : "^6.9.2"
, "eval" : "^0.1.1"
, "mustache" : "^2.2.1"
}
, "devDependencies": {
"flow-bin" : "^0.24.0"
, "babel-cli" : "^6.9.0"
, "babel-register" : "^6.9.0"
, "babel-preset-es2015" : "^6.9.0"
, "babel-preset-stage-2" : "^6.5.0"
, "babel-plugin-transform-runtime" : "^6.9.0"
, "babel-plugin-transform-flow-comments" : "^6.8.0"
, "babel-plugin-espower" : "^2.2.0"
, "babel-plugin-unassert" : "^2.1.0"
, "babel-plugin-istanbul" : "^2.0.0"
, "mocha" : "^2.5.3"
, "power-assert" : "^1.4.1"
, "sinon" : "^1.17.4"
}
}
#!/usr/bin/env sh
set +o verbose
# Usage:
# ------
# FIXME: Document this testing script.
#
# Mostly copied from Paws.js and/or mocha-before-this:
# <https://github.com/ELLIOTTCABLE/Paws.js/blob/6f77f3e1/Scripts/test.sh>
# <https://github.com/ELLIOTTCABLE/mocha-before-this/blob/e8450e82/test.sh>
puts() { printf %s\\n "$@" ;}
pute() { printf %s\\n "~~ $*" >&2 ;}
argq() { [ $# -gt 0 ] && printf "'%s' " "$@" ;}
source_dir="$npm_package_directories_src"
unit_dir="$npm_package_directories_test"
coverage_dir="$npm_package_directories_coverage"
mocha_ui="$npm_package_config_mocha_ui"
mocha_reporter="$npm_package_config_mocha_reporter"
# FIXME: This should support *excluded* modules with a minus, as per `node-debug`:
# https://github.com/visionmedia/debug
if echo "$DEBUG" | grep -qE '(^|,\s*)(\*|giraphe(:(scripts|\*))?)($|,)'; then
pute "Script debugging enabled (in: `basename $0`)."
DEBUG_SCRIPTS=yes
VERBOSE="${VERBOSE:-7}"
fi
# Configuration-variable setup
# ----------------------------
[ -z "${SILENT##[NFnf]*}${QUIET##[NFnf]*}" ] && [ "${VERBOSE:-4}" -gt 6 ] && print_commands=yes
if [ -n "${DEBUGGER##[NFnf]*}" ]; then
[ ! -x "./node_modules/.bin/node-debug" ] && \
pute 'You must `npm install node-inspector` to use the $DEBUGGER flag!' && exit 127
WATCH='no'
COVERAGE='no'
[ -z "${DEBUG_MODULES##[NFnf]*}" ] && \
hidden='--hidden node_modules/'
invocation_guard="./node_modules/.bin/node-debug $hidden --cli --config './Scripts/node-inspectorrc.json'"
fi
if [ -n "${WATCH##[NFnf]*}" ]; then
[ ! -x "./node_modules/.bin/chokidar" ] &&
pute 'You must `npm install chokidar-cli` to use the $WATCH flag!' && exit 127
fi
if [ -n "${COVERAGE##[NFnf]*}" ]; then
[ ! -x "./node_modules/.bin/nyc" ] &&
pute 'You must `npm install nyc` to use the $COVERAGE flag!' && exit 127
WATCH='no'
coverage=yes # Alias so I can stop tying `NFnf` :P
export NODE_ENV='coverage'
invocation_guard="nyc"
fi
[ -n "$DEBUG_SCRIPTS" ] && puts \
"Watching filesystem: ${WATCH:--}" \
"Running debugger: ${DEBUGGER:--}" \
"Generating coverage: ${COVERAGE:--}" \
"Debugging modules: ${DEBUG_MODULES:--}" \
"" \
"Verbosity: '$VERBOSE'" \
"Printing commands: ${print_commands:--}" \
"" \
"Tests directory: '$unit_dir'" \
"Coverage directory: '$coverage_dir'" \
"" >&2
[ -n "$DEBUG_SCRIPTS" ] && [ "${VERBOSE:-4}" -gt 8 ] && \
pute "Environment variables:" && env >&2
# Helper-function setup
# ---------------------
go () { [ -n "$print_commands" ] && puts '`` '"$*" >&2 ; "$@" || exit $? ;}
mochaify() {
[ "$coverage" != yes ] && compilers_flag="--compilers js:babel-register"
go $invocation_guard "./node_modules/.bin/${invocation_guard:+_}mocha" \
${invocation_guard:+ --no-timeouts } \
$compilers_flag --reporter "$mocha_reporter" --ui "$mocha_ui" \
"$@" ;}
# --require mocha-clean/brief \
# Execution of tests
# ------------------
if [ -n "${WATCH##[NFnf]*}" ]; then
[ "${VERBOSE:-4}" -gt 7 ] && chokidar_verbosity='--verbose'
unset WATCH COVERAGE DEBUGGER
export VERBOSE
go exec chokidar \
"${chokidar_verbosity:---silent}" \
--initial --ignore '**/.*' \
"$source_dir" "$unit_dir" \
$CHOKIDAR_FLAGS -c "$0 $(argq "$@")"
fi
mochaify "$unit_dir"/"*.tests.*js" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment