Skip to content

Commit bf91035

Browse files
committed
process: fix handling of process.noDeprecation in emitWarning
PR-URL: #8166 Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent 2d2a2d7 commit bf91035

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/internal/process/warning.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
'use strict';
22

3-
const traceWarnings = process.traceProcessWarnings;
4-
const noDeprecation = process.noDeprecation;
5-
const traceDeprecation = process.traceDeprecation;
6-
const throwDeprecation = process.throwDeprecation;
73
const prefix = `(${process.release.name}:${process.pid}) `;
84

95
exports.setup = setupProcessWarnings;
@@ -13,8 +9,9 @@ function setupProcessWarnings() {
139
process.on('warning', (warning) => {
1410
if (!(warning instanceof Error)) return;
1511
const isDeprecation = warning.name === 'DeprecationWarning';
16-
if (isDeprecation && noDeprecation) return;
17-
const trace = traceWarnings || (isDeprecation && traceDeprecation);
12+
if (isDeprecation && process.noDeprecation) return;
13+
const trace = process.traceProcessWarnings ||
14+
(isDeprecation && process.traceDeprecation);
1815
if (trace && warning.stack) {
1916
console.error(`${prefix}${warning.stack}`);
2017
} else {
@@ -41,9 +38,12 @@ function setupProcessWarnings() {
4138
if (!(warning instanceof Error)) {
4239
throw new TypeError('\'warning\' must be an Error object or string.');
4340
}
44-
if (throwDeprecation && warning.name === 'DeprecationWarning')
45-
throw warning;
46-
else
47-
process.nextTick(() => process.emit('warning', warning));
41+
if (warning.name === 'DeprecationWarning') {
42+
if (process.noDeprecation)
43+
return;
44+
if (process.throwDeprecation)
45+
throw warning;
46+
}
47+
process.nextTick(() => process.emit('warning', warning));
4848
};
4949
}

0 commit comments

Comments
 (0)