From 64e11918891b4a55ac7c21df1bff7eb1ed2e8a71 Mon Sep 17 00:00:00 2001 From: Rowan Cockett Date: Thu, 22 Aug 2024 12:16:49 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A4=AB=20Quiet=20warning=20about=20`punyc?= =?UTF-8?q?ode`=20(#1485)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1166 --- .changeset/nasty-suits-study.md | 6 ++++++ packages/myst-cli/src/build/site/logger.ts | 2 ++ packages/mystmd/src/index.ts | 12 ++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 .changeset/nasty-suits-study.md diff --git a/.changeset/nasty-suits-study.md b/.changeset/nasty-suits-study.md new file mode 100644 index 000000000..bea857e3a --- /dev/null +++ b/.changeset/nasty-suits-study.md @@ -0,0 +1,6 @@ +--- +"myst-cli": patch +"mystmd": patch +--- + +Suppress punycode deprecation warning diff --git a/packages/myst-cli/src/build/site/logger.ts b/packages/myst-cli/src/build/site/logger.ts index 763ea5629..8d334b367 100644 --- a/packages/myst-cli/src/build/site/logger.ts +++ b/packages/myst-cli/src/build/site/logger.ts @@ -32,6 +32,8 @@ export function createServerLogger(session: ISession, ready: () => void): Logger // This is a spurious Remix warning https://github.com/remix-run/remix/issues/2677 if (line.includes('is not listed in your package.json dependencies')) return; if (line.includes('was not found in your node_modules')) return; + // This is the punycode deprecation warning + if (line.includes('--trace-deprecation') || line.includes('DEP0040')) return; if (line.startsWith('Rebuilding')) { session.log.debug(line); return; diff --git a/packages/mystmd/src/index.ts b/packages/mystmd/src/index.ts index d08353bb8..144f9b5d8 100644 --- a/packages/mystmd/src/index.ts +++ b/packages/mystmd/src/index.ts @@ -1,5 +1,17 @@ #!/usr/bin/env node import 'core-js/actual'; // This adds backwards compatible functionality for various CLIs + +// This suppresses the punycode deprecation warning +// https://github.com/jupyter-book/mystmd/issues/1166 +const { emit: originalEmit } = process; +function suppressor(event: string, error: Error) { + return event === 'warning' && error.name === 'DeprecationWarning' + ? false + : // eslint-disable-next-line prefer-rest-params + originalEmit.apply(process, arguments); +} +(process as any).emit = suppressor; + import { Command } from 'commander'; import version from './version.js'; import { makeBuildCLI } from './build.js';