Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

fix deprecation warning when using `path.existsSync`

Nathan Rajliche1873ba40596
diff --git a/bin/_mocha b/bin/_mocha
index 5eded0d0..af6bcbea 100755
--- a/bin/_mocha
+++ b/bin/_mocha
@@ -7,8 +7,10 @@
var program = require('commander')
, exec = require('child_process').exec
, path = require('path')
+ , fs = require('fs')
+ , vm = require('vm')
, resolve = path.resolve
- , exists = path.existsSync
+ , exists = fs.existsSync || path.existsSync
, mocha = require('../')
, utils = mocha.utils
, reporters = mocha.reporters
@@ -16,8 +18,6 @@ var program = require('commander')
, Context = mocha.Context
, Runner = mocha.Runner
, Suite = mocha.Suite
- , vm = require('vm')
- , fs = require('fs')
, join = path.join
, cwd = process.cwd();
@@ -141,8 +141,8 @@ program.on('interfaces', function(){
module.paths.push(cwd, join(cwd, 'node_modules'));
program.on('require', function(mod){
- var abs = path.existsSync(mod)
- || path.existsSync(mod + '.js');
+ var abs = exists(mod)
+ || exists(mod + '.js');
if (abs) mod = join(cwd, mod);
require(mod);