diff --git a/configure-inquirer-stub.js b/configure-inquirer-stub.js index c71ddb3..975451e 100644 --- a/configure-inquirer-stub.js +++ b/configure-inquirer-stub.js @@ -1,7 +1,6 @@ 'use strict'; const sinon = require('sinon'); -const preventCircularDepPropertyWarning = require('./prevent-circular-dep-property-warning'); const validatedTypes = new Set(['input', 'password']); @@ -31,7 +30,6 @@ module.exports = (inquirer, config) => { if (inquirer.prompt.restore) inquirer.prompt.restore(); if (inquirer.createPromptModule.restore) inquirer.createPromptModule.restore(); - const { restore: restoreProcessWarnings } = preventCircularDepPropertyWarning(); sinon.stub(inquirer, 'prompt').callsFake((promptConfig) => { if (!Array.isArray(promptConfig)) return resolveAnswer(promptConfig); const result = {}; @@ -46,6 +44,5 @@ module.exports = (inquirer, config) => { }); sinon.stub(inquirer, 'createPromptModule').callsFake(() => inquirer.prompt); - restoreProcessWarnings(); return inquirer; }; diff --git a/docs/prevent-circular-dep-property-warning.md b/docs/prevent-circular-dep-property-warning.md deleted file mode 100644 index 1092015..0000000 --- a/docs/prevent-circular-dep-property-warning.md +++ /dev/null @@ -1,19 +0,0 @@ -# prevent-circular-dep-property-warning - -In tests we mock modules with variants that expose subset of properties, additionally modules cache is tweaked so new require's that points those modules exports mocks and not original exports. - -This actually provokes nasty warnings with Node.js v14. Complained about it here: -https://github.com/nodejs/node/pull/31000#issuecomment-628502264 - -Until it's fixed on Node.js side, or a solution to limit just this warning is introduced, this patch is needed to. - -Usage: - -```javascript -const preventCircularDepPropertyWarning = require('@serverless/test/prevent-circular-dep-property-warning'); - -// Initialize right before mocks are processed -const { restore: restoreProcessWarnings } = preventCircularDepPropertyWarning(); -// .. mocks processing -restoreProcessWarnings(); // Restore original warnings state -``` diff --git a/prevent-circular-dep-property-warning.js b/prevent-circular-dep-property-warning.js deleted file mode 100644 index d8ffc03..0000000 --- a/prevent-circular-dep-property-warning.js +++ /dev/null @@ -1,28 +0,0 @@ -// Temporary workaround, until Node.js has: https://github.com/nodejs/node/pull/31000 - -'use strict'; - -const nodeMajorVersion = Number(process.version.split('.')[0].slice(1)); - -if (nodeMajorVersion < 14) { - module.exports = () => ({ restore: () => {} }); - return; -} - -module.exports = () => { - const processEmitWarning = process.emitWarning; - process.emitWarning = (warning, ...args) => { - if ( - typeof warning === 'string' && - warning.includes('of module exports inside circular dependency') - ) { - return; - } - processEmitWarning.call(this, warning, ...args); - }; - return { - restore: () => { - process.emitWarning = processEmitWarning; - }, - }; -}; diff --git a/run-serverless.js b/run-serverless.js index 2d4616b..bc3bc25 100644 --- a/run-serverless.js +++ b/run-serverless.js @@ -19,7 +19,6 @@ const observeOutput = require('./observe-output'); const disableServerlessStatsRequests = require('./disable-serverless-stats-requests'); const provisionTmpDir = require('./provision-tmp-dir'); const configureAwsRequestStub = require('./configure-aws-request-stub'); -const preventCircularDepPropertyWarning = require('./prevent-circular-dep-property-warning'); const resolveServerless = async (serverlessPath, modulesCacheStub, callback) => { if (!modulesCacheStub) { @@ -27,7 +26,6 @@ const resolveServerless = async (serverlessPath, modulesCacheStub, callback) => return callback(require(serverlessPath)); } - const { restore: restoreProcessWarnings } = preventCircularDepPropertyWarning(); const originalCache = Object.assign({}, require.cache); for (const key of Object.keys(require.cache)) delete require.cache[key]; disableServerlessStatsRequests(serverlessPath); @@ -40,7 +38,6 @@ const resolveServerless = async (serverlessPath, modulesCacheStub, callback) => const restore = () => { for (const key of Object.keys(require.cache)) delete require.cache[key]; Object.assign(require.cache, originalCache); - restoreProcessWarnings(); }; try { return await callback(require(serverlessPath));