summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine du Hamel <duhamelantoine1995@gmail.com>2020-09-08 00:10:44 +0200
committerBeth Griggs <bgriggs@redhat.com>2021-07-29 11:56:47 +0100
commiteccc9a6578610c48aadc9dea5b4e391cab7fc791 (patch)
tree3fa1094a4bb1cfde51b4062121c97f59da7125ab
parenta082a705b391712758ec9e296ca62653b458f841 (diff)
downloadnode-new-eccc9a6578610c48aadc9dea5b4e391cab7fc791.tar.gz
punycode: add pending deprecation
PR-URL: https://github.com/nodejs/node/pull/38444 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
-rw-r--r--doc/api/deprecations.md5
-rw-r--r--lib/punycode.js10
-rw-r--r--test/message/core_line_numbers.out4
-rw-r--r--test/parallel/test-punycode.js10
4 files changed, 25 insertions, 4 deletions
diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md
index 68e5777ddd..2e91a34b5d 100644
--- a/doc/api/deprecations.md
+++ b/doc/api/deprecations.md
@@ -831,12 +831,15 @@ The [`require.extensions`][] property is deprecated.
### DEP0040: `punycode` module
<!-- YAML
changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/38444
+ description: Added support for `--pending-deprecation`.
- version: v7.0.0
pr-url: https://github.com/nodejs/node/pull/7941
description: Documentation-only deprecation.
-->
-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 67905e3d76..3483fd667b 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 215542404b..97b017f66e 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.<anonymous> (*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 190c0b22b3..efd3b92a6e 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');