From 89b4770d5c9cde6e21ae95dd4018d02c24d459f0 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 8 Sep 2020 00:10:44 +0200 Subject: [PATCH] punycode: add pending deprecation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/38444 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Michaƫl Zasso Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat --- doc/api/deprecations.md | 5 ++++- lib/punycode.js | 10 ++++++++++ test/message/core_line_numbers.out | 4 ++-- test/parallel/test-punycode.js | 10 +++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 68e5777ddd90c4..2e91a34b5d2f00 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/message/core_line_numbers.out b/test/message/core_line_numbers.out index 215542404be02f..97b017f66e2395 100644 --- a/test/message/core_line_numbers.out +++ b/test/message/core_line_numbers.out @@ -1,9 +1,9 @@ -node:punycode:42 +node:punycode:52 throw new RangeError(errors[type]); ^ RangeError: Invalid input - at error (node:punycode:42:8) + at error (node:punycode:52:8) at Object.decode (node:punycode:*:*) at Object. (*test*message*core_line_numbers.js:*:*) at Module._compile (node:internal/modules/cjs/loader:*:*) 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');