Skip to content
Merged
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
5 changes: 2 additions & 3 deletions lib/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var resolveFrom = require('resolve-from');
var createEspowerPlugin = require('babel-plugin-espower/create');

var hasGenerators = parseInt(process.version.slice(1), 10) > 0;
var path = process.argv[2];

var options = {
only: /(test|test\-.+|test\/.+)\.js$/,
only: path,
blacklist: hasGenerators ? ['regenerator'] : [],
optional: hasGenerators ? ['asyncToGenerator'] : [],
plugins: [
Expand All @@ -24,6 +25,4 @@ try {
require('babel-core/register')(options);
}

var path = process.argv[2];

require(path);
1 change: 1 addition & 0 deletions test/fixture/babel-hook-imported.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.export = async () => {};
1 change: 1 addition & 0 deletions test/fixture/babel-hook.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import x from './babel-hook-imported';
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,11 @@ test('change process.cwd() to a test\'s directory', function (t) {
t.end();
});
});

test('Babel require hook only applies to the test file', function (t) {
execCli('fixture/babel-hook.js', function (err) {
t.ok(err);
t.is(err.code, 1);
t.end();
});
});