Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

ESM: proper version check in hasStableEsmImplementation (#4653)

Alexander Fensterb20f3c953d21
diff --git a/lib/esm-utils.js b/lib/esm-utils.js
index 14a9c28f..d4acf06c 100644
--- a/lib/esm-utils.js
+++ b/lib/esm-utils.js
@@ -34,7 +34,9 @@ const hasStableEsmImplementation = (() => {
const [major, minor] = process.version.split('.');
// ESM is stable from v12.22.0 onward
// https://nodejs.org/api/esm.html#esm_modules_ecmascript_modules
- return parseInt(major.slice(1), 10) > 12 || parseInt(minor, 10) >= 22;
+ const majorNumber = parseInt(major.slice(1), 10);
+ const minorNumber = parseInt(minor, 10);
+ return majorNumber > 12 || (majorNumber === 12 && minorNumber >= 22);
})();
exports.requireOrImport = hasStableEsmImplementation