From bd2fbdeff1d0cde78a869092cfe769c62d8863f2 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 5 Nov 2021 19:32:07 -0700 Subject: [PATCH 1/3] try to null getSource export --- src/esmockLoader.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/esmockLoader.mjs b/src/esmockLoader.mjs index c20698be..3cd6a46e 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 nodelte1612 = nodeMjr < 16 || (nodeMjr === 16 && nodeMnr <= 12); + +async function getSource (url, context, defaultGetSource) { return load(url, context, defaultGetSource); } + +if (!nodelte1612) { + getSource = null; +} + +export { getSource }; From 8435676c1728c9e692aa0e47f21bcc8d084dd274 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 5 Nov 2021 19:39:59 -0700 Subject: [PATCH 2/3] update package.json, add comment, update readme --- README.md | 3 ++- package.json | 3 ++- src/esmockLoader.mjs | 8 ++++---- 3 files changed, 8 insertions(+), 6 deletions(-) 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.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 3cd6a46e..dc07e538 100644 --- a/src/esmockLoader.mjs +++ b/src/esmockLoader.mjs @@ -66,14 +66,14 @@ export async function load (url, context, defaultGetSource) { // supported by node version less than 16.12 const [ nodeMjr, nodeMnr ] = process.versions.node.split('.').map(Number); -const nodelte1612 = nodeMjr < 16 || (nodeMjr === 16 && nodeMnr <= 12); +const nodelt1612 = nodeMjr < 16 || (nodeMjr === 16 && nodeMnr < 12); async function getSource (url, context, defaultGetSource) { return load(url, context, defaultGetSource); } -if (!nodelte1612) { - getSource = null; -} +// make this null node versions after 16.11 so taht warning message +// is not printed +if (!nodelt1612) getSource = null; export { getSource }; From 42d940a07474046e4e48dd93a6a43727d9637824 Mon Sep 17 00:00:00 2001 From: chris Date: Fri, 5 Nov 2021 19:40:45 -0700 Subject: [PATCH 3/3] update package-lock.json --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"