Skip to content

Commit

Permalink
treat '--require esm' as Node option
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Aug 11, 2019
1 parent a3c62cd commit 14d7320
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions bin/mocha
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,17 @@ if (nodeArgs.gc) {
delete nodeArgs.gc;
}

if (
Object.keys(nodeArgs).length ||
(mochaArgs.require && mochaArgs.require.includes('esm'))
) {
// --require/-r is treated as Mocha flag except when 'esm' is preloaded
if (mochaArgs.require && mochaArgs.require.includes('esm')) {
nodeArgs.require = ['esm'];
mochaArgs.require = mochaArgs.require.filter(mod => mod !== 'esm');
if (!mochaArgs.require.length) {
delete mochaArgs.require;
}
delete mochaArgs.r;
}

if (Object.keys(nodeArgs).length) {
const {spawn} = require('child_process');
const mochaPath = require.resolve('../lib/cli/cli.js');

Expand Down

0 comments on commit 14d7320

Please sign in to comment.