Skip to content

Commit

Permalink
supportsEsModule default is now to check support for full (>=v12) spe…
Browse files Browse the repository at this point in the history
…cification
  • Loading branch information
giltayar authored and boneskull committed Jun 5, 2020
1 parent 62e15dd commit 0fbffc6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion lib/mocha.js
Expand Up @@ -14,7 +14,7 @@ var utils = require('./utils');
var mocharc = require('./mocharc.json');
var errors = require('./errors');
var Suite = require('./suite');
var esmUtils = utils.supportsEsModules(false)
var esmUtils = utils.supportsEsModules(true)
? require('./esm-utils')
: undefined;
var createStatsCollector = require('./stats-collector');
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.js
Expand Up @@ -808,17 +808,17 @@ exports.defineConstants = function(obj) {
* This function returns whether Node.JS has ES Module supports that is compatible with Mocha's needs,
* which is version >=12.11.
*
* @param {fullSpecification} whether the full Node.js ESM support is available (>= 12) or just something that supports the runtime (>= 10)
* @param {partialSupport} whether the full Node.js ESM support is available (>= 12) or just something that supports the runtime (>= 10)
*
* @returns {Boolean} whether the current version of Node.JS supports ES Modules in a way that is compatible with Mocha
*/
exports.supportsEsModules = function(fullSpecification) {
exports.supportsEsModules = function(partialSupport) {
if (!exports.isBrowser() && process.versions && process.versions.node) {
var versionFields = process.versions.node.split('.');
var major = +versionFields[0];
var minor = +versionFields[1];

if (fullSpecification) {
if (!partialSupport) {
return major >= 13 || (major === 12 && minor >= 11);
} else {
return major >= 10;
Expand Down

0 comments on commit 0fbffc6

Please sign in to comment.