Skip to content

Commit

Permalink
Add patch for mocha test runner colors
Browse files Browse the repository at this point in the history
  • Loading branch information
nylen committed Mar 29, 2015
1 parent cbf2055 commit 9491e5b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions _actions/mocha.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--- _mocha
+++ _mocha
@@ -1,3 +1,9 @@
+// Fix expected/actual colors with Solarized
+// https://github.com/mochajs/mocha/issues/1200#issuecomment-62780003
+var colors = require('../lib/reporters/base').colors;
+colors['diff added'] = '32;40';
+colors['diff removed'] = '32;40';
+
/**
* Module dependencies.
*/
33 changes: 33 additions & 0 deletions _actions/patch-mocha.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

_mocha=$(which _mocha)

if [ ! -r "$_mocha" ]; then
# _mocha executable not present
exit
fi

if head -n 1 "$_mocha" | grep -q Solarized; then
# _mocha executable already patched
exit
fi

# resolve any symlinks in path to _mocha - otherwise patch will change _mocha
# from a symlink to a regular file, and Node.js require will not work properly
while [ -L "$_mocha" ]; do
pushd "$(dirname "$_mocha")" > /dev/null
pushd "$(dirname "$(readlink "$_mocha")")" > /dev/null
_mocha="$(pwd)/_mocha"
popd > /dev/null
popd > /dev/null
done

if [ ! -w "$_mocha" ]; then
# cannot write to _mocha executable
echo "WARNING: Failed to patch _mocha ($_mocha) - try this:"
echo " sudo $0"
exit
fi

cd "$(dirname "$0")"
patch --directory "$(dirname "$_mocha")" -p0 < mocha.diff

0 comments on commit 9491e5b

Please sign in to comment.