diff --git a/api.js b/api.js index f8e8937e8..f583cc642 100644 --- a/api.js +++ b/api.js @@ -9,6 +9,7 @@ var figures = require('figures'); var globby = require('globby'); var chalk = require('chalk'); var fork = require('./lib/fork'); +var resolveCwd = require('resolve-cwd'); var formatter = require('./lib/enhance-assert').formatter(); function Api(files, options) { @@ -20,6 +21,8 @@ function Api(files, options) { this.options = options || {}; + this.options.require = (this.options.require || []).map(resolveCwd); + this.rejectionCount = 0; this.exceptionCount = 0; this.passCount = 0; diff --git a/lib/babel.js b/lib/babel.js index a792a85c3..849bdbb77 100644 --- a/lib/babel.js +++ b/lib/babel.js @@ -16,10 +16,7 @@ if (debug.enabled) { // Bind globals first, before anything has a chance to interfere. var globals = require('./globals'); -var resolveCwd = require('resolve-cwd'); -(opts.require || []).forEach(function (moduleId) { - require(resolveCwd(moduleId)); -}); +(opts.require || []).forEach(require); var sourceMapCache = Object.create(null); diff --git a/test/api.js b/test/api.js index dbbf7fe43..dcf64fb20 100644 --- a/test/api.js +++ b/test/api.js @@ -314,9 +314,12 @@ test('test file in node_modules is ignored', function (t) { test('Node.js-style --require CLI argument', function (t) { t.plan(1); + var requirePath = path.relative(process.cwd(), path.join(__dirname, 'fixture', 'install-global.js')); + requirePath = '.' + path.sep + requirePath; + var api = new Api( [path.join(__dirname, 'fixture/validate-installed-global.js')], - {require: [path.join(__dirname, 'fixture', 'install-global.js')]} + {require: [requirePath]} ); api.run()