From 989bdd102477f2ac4bd383814c075c1f309931f5 Mon Sep 17 00:00:00 2001 From: Aman Kumar Date: Tue, 4 Jun 2024 14:16:53 +0530 Subject: [PATCH] fix: handle deprecation warning message --- packages/contentstack/bin/run.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/contentstack/bin/run.js b/packages/contentstack/bin/run.js index 0dfee626ce..8eefb28744 100755 --- a/packages/contentstack/bin/run.js +++ b/packages/contentstack/bin/run.js @@ -1,6 +1,23 @@ #!/usr/bin/env node // eslint-disable-next-line unicorn/prefer-top-level-await (async () => { - const oclif = await import('@oclif/core'); - await oclif.execute({ development: false, dir: __dirname }); + try { + // Store the original process.emitWarning function + const originalEmitWarning = process.emitWarning; + + // Override process.emitWarning to filter out the punycode deprecation warning + process.emitWarning = (warning, type, code, ...args) => { + if (type === 'DeprecationWarning' && typeof warning === 'string' && warning.includes('punycode')) { + // Ignore punycode deprecation warning + return; + } + // Call the original emitWarning function for other warnings + originalEmitWarning.call(process, warning, type, code, ...args); + }; + + const oclif = await import('@oclif/core'); + await oclif.execute({ development: false, dir: __dirname }); + } catch (error) { + console.error('An error occurred while executing oclif:', error); + } })();