Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make --require relative to where the command is run. #346

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 3 additions & 0 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this above fork.

var formatter = require('./lib/enhance-assert').formatter();

function Api(files, options) {
Expand All @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions lib/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down