Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var _ = require('lodash'),
streamBuffers = require("stream-buffers"),
through = require('through'),
split = require('split'),
fs = require('fs');
fs = require('fs'),
os = require('os');

require('colors');

Expand All @@ -22,6 +23,11 @@ function newStreamBuffer() {
return stream;
}

var getNpmBin = _.memoize(function getNpmBin () {
// this only happens once, so sync is fine
return proc.execSync('npm bin', {encoding: 'utf8'}).trim();
});

var SpawnMocha = function (opts) {
var _this = this;
opts = opts || {};
Expand All @@ -30,8 +36,10 @@ var SpawnMocha = function (opts) {
});
var queue = async.queue(function (task, done) {
// Setup
var bin = _.isFunction(opts.bin) ? opts.bin() : opts.bin ||
join(__dirname, 'node_modules', '.bin', 'mocha');
var bin = _.isFunction(opts.bin)
? opts.bin()
: opts.bin
|| join(getNpmBin(), os.platform === 'win32' ? 'mocha.md' : 'mocha');
var env = _.isFunction(opts.env) ? opts.env() : opts.env || process.env;
env = _.clone(env);

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"husky": "^2.0.0",
"vinyl": "^2.0.0"
},
"peerDependency": {
"mocha": "^6.0.0"
},
"engines": {
"node": ">= 0.9.0"
},
Expand Down