From f6d0ee60c41c891b6e7d3358e2b57ce703ec131f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 8 Sep 2020 00:10:44 +0200 Subject: [PATCH 1/3] punycode: add pending deprecation --- doc/api/deprecations.md | 5 ++++- lib/punycode.js | 10 ++++++++++ test/parallel/test-punycode.js | 10 +++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index cc6b61206c5efe..b2d32a0ee601dc 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -831,12 +831,15 @@ The [`require.extensions`][] property is deprecated. ### DEP0040: `punycode` module -Type: Documentation-only +Type: Documentation-only (supports [`--pending-deprecation`][]) The [`punycode`][] module is deprecated. Please use a userland alternative instead. diff --git a/lib/punycode.js b/lib/punycode.js index 67905e3d7670e1..3483fd667bf40a 100644 --- a/lib/punycode.js +++ b/lib/punycode.js @@ -1,5 +1,15 @@ 'use strict'; +const { getOptionValue } = require('internal/options'); +if (getOptionValue('--pending-deprecation')){ + process.emitWarning( + 'The `punycode` module is deprecated. Please use a userland ' + + 'alternative instead.', + 'DeprecationWarning', + 'DEP0040', + ); +} + /** Highest positive signed 32-bit float value */ const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1 diff --git a/test/parallel/test-punycode.js b/test/parallel/test-punycode.js index 190c0b22b313dc..efd3b92a6e7e50 100644 --- a/test/parallel/test-punycode.js +++ b/test/parallel/test-punycode.js @@ -1,3 +1,5 @@ +// Flags: --pending-deprecation + // Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a @@ -20,7 +22,13 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); + +const punycodeWarning = + 'The `punycode` module is deprecated. Please use a userland alternative ' + + 'instead.'; +common.expectWarning('DeprecationWarning', punycodeWarning, 'DEP0040'); + const punycode = require('punycode'); const assert = require('assert'); From 2299ab18b33eb7eec11ec2aaf20b3eeccbd2b1b0 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 28 Apr 2021 00:06:12 +0200 Subject: [PATCH 2/3] fixup! punycode: add pending deprecation --- doc/api/deprecations.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index b2d32a0ee601dc..a0140b16e9b7cc 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -832,7 +832,7 @@ The [`require.extensions`][] property is deprecated.