Skip to content

Commit 40ea8aa

Browse files
aduh95jasnell
authored andcommittedApr 30, 2021
punycode: add pending deprecation
PR-URL: nodejs#38444 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 6434cd6 commit 40ea8aa

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed
 

‎doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -831,12 +831,15 @@ The [`require.extensions`][] property is deprecated.
831831
### DEP0040: `punycode` module
832832
<!-- YAML
833833
changes:
834+
- version: REPLACEME
835+
pr-url: https://github.com/nodejs/node/pull/38444
836+
description: Added support for `--pending-deprecation`.
834837
- version: v7.0.0
835838
pr-url: https://github.com/nodejs/node/pull/7941
836839
description: Documentation-only deprecation.
837840
-->
838841

839-
Type: Documentation-only
842+
Type: Documentation-only (supports [`--pending-deprecation`][])
840843

841844
The [`punycode`][] module is deprecated. Please use a userland alternative
842845
instead.

‎lib/punycode.js

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
'use strict';
22

3+
const { getOptionValue } = require('internal/options');
4+
if (getOptionValue('--pending-deprecation')){
5+
process.emitWarning(
6+
'The `punycode` module is deprecated. Please use a userland ' +
7+
'alternative instead.',
8+
'DeprecationWarning',
9+
'DEP0040',
10+
);
11+
}
12+
313
/** Highest positive signed 32-bit float value */
414
const maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
515

‎test/message/core_line_numbers.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
node:punycode:42
1+
node:punycode:52
22
throw new RangeError(errors[type]);
33
^
44

55
RangeError: Invalid input
6-
at error (node:punycode:42:8)
6+
at error (node:punycode:52:8)
77
at Object.decode (node:punycode:*:*)
88
at Object.<anonymous> (*test*message*core_line_numbers.js:*:*)
99
at Module._compile (node:internal/modules/cjs/loader:*:*)

‎test/parallel/test-punycode.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Flags: --pending-deprecation
2+
13
// Copyright Joyent, Inc. and other Node contributors.
24
//
35
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -20,7 +22,13 @@
2022
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2123

2224
'use strict';
23-
require('../common');
25+
const common = require('../common');
26+
27+
const punycodeWarning =
28+
'The `punycode` module is deprecated. Please use a userland alternative ' +
29+
'instead.';
30+
common.expectWarning('DeprecationWarning', punycodeWarning, 'DEP0040');
31+
2432
const punycode = require('punycode');
2533
const assert = require('assert');
2634

0 commit comments

Comments
 (0)
Please sign in to comment.