diff --git a/README.md b/README.md index b099eb78..53889c77 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,8 @@ test('should mock modules and local files at same time', async t => { ### changelog * 1.0.1 _Nov.02.2001_ - * add node v17.x to testing pipelin + * add node v17.x to testing pipeline + * add, make warning message go away for node 16.12.0+ * 1.0.0 _Oct.27.2001_ * release version 1.0 * 0.4.2 _Oct.27.2021_ diff --git a/package-lock.json b/package-lock.json index 1b90bdca..23a29be7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "esmock", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "esmock", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "dependencies": { "resolvewithplus": "^0.2.0" diff --git a/package.json b/package.json index 1aa36b0b..bed497fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "esmock", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "readmeFilename": "README.md", "description": "mock esm modules for unit-tests", @@ -57,6 +57,7 @@ }, "scripts": { "test": "ava --node-arguments=\"--loader=./src/esmockLoader.mjs\"", + "test-no-warn": "ava --node-arguments=\"--loader=./src/esmockLoader.mjs --no-warnings\"", "lint": "eslint src/*js spec/*js" } } diff --git a/src/esmockLoader.mjs b/src/esmockLoader.mjs index c20698be..dc07e538 100644 --- a/src/esmockLoader.mjs +++ b/src/esmockLoader.mjs @@ -65,6 +65,15 @@ export async function load (url, context, defaultGetSource) { } // supported by node version less than 16.12 -export async function getSource (url, context, defaultGetSource) { +const [ nodeMjr, nodeMnr ] = process.versions.node.split('.').map(Number); +const nodelt1612 = nodeMjr < 16 || (nodeMjr === 16 && nodeMnr < 12); + +async function getSource (url, context, defaultGetSource) { return load(url, context, defaultGetSource); } + +// make this null node versions after 16.11 so taht warning message +// is not printed +if (!nodelt1612) getSource = null; + +export { getSource };