From 915351fec52c682453fbc843a97caf64ca62a678 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 7 Mar 2017 18:21:13 +0700 Subject: [PATCH] Use the local Mocha dependency of this package So it no longer requires having Mocha installed globally --- index.js | 6 +++++- package.json | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index d19e8bb..101d19a 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,8 @@ const dargs = require('dargs'); const execa = require('execa'); const gutil = require('gulp-util'); const through = require('through2'); +// TODO: Use execa localDir option when available +const npmRunPath = require('npm-run-path'); module.exports = opts => { opts = Object.assign({ @@ -38,7 +40,9 @@ module.exports = opts => { } function flush(done) { - let proc = execa('mocha', files.concat(args)); + const env = npmRunPath.env({cwd: __dirname}); + const proc = execa('mocha', files.concat(args), {env}); + proc.then(result => { this.emit('_result', result); done(); diff --git a/package.json b/package.json index 2cf2b54..ada6bf7 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "execa": "^0.6.0", "gulp-util": "^3.0.0", "mocha": "^3.0.0", + "npm-run-path": "^2.0.2", "through2": "^2.0.3" }, "devDependencies": {