Permalink
Browse files

process: fix handling of process.noDeprecation in emitWarning

PR-URL: #8166
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information...
jasnell committed Aug 18, 2016
1 parent 2d2a2d7 commit bf91035364784ab2faf4a81af4e116345e388444
Showing with 10 additions and 10 deletions.
  1. +10 −10 lib/internal/process/warning.js
@@ -1,9 +1,5 @@
'use strict';
const traceWarnings = process.traceProcessWarnings;
const noDeprecation = process.noDeprecation;
const traceDeprecation = process.traceDeprecation;
const throwDeprecation = process.throwDeprecation;
const prefix = `(${process.release.name}:${process.pid}) `;
exports.setup = setupProcessWarnings;
@@ -13,8 +9,9 @@ function setupProcessWarnings() {
process.on('warning', (warning) => {
if (!(warning instanceof Error)) return;
const isDeprecation = warning.name === 'DeprecationWarning';
if (isDeprecation && noDeprecation) return;
const trace = traceWarnings || (isDeprecation && traceDeprecation);
if (isDeprecation && process.noDeprecation) return;
const trace = process.traceProcessWarnings ||
(isDeprecation && process.traceDeprecation);
if (trace && warning.stack) {
console.error(`${prefix}${warning.stack}`);
} else {
@@ -41,9 +38,12 @@ function setupProcessWarnings() {
if (!(warning instanceof Error)) {
throw new TypeError('\'warning\' must be an Error object or string.');
}
if (throwDeprecation && warning.name === 'DeprecationWarning')
throw warning;
else
process.nextTick(() => process.emit('warning', warning));
if (warning.name === 'DeprecationWarning') {
if (process.noDeprecation)
return;
if (process.throwDeprecation)
throw warning;
}
process.nextTick(() => process.emit('warning', warning));
};
}

0 comments on commit bf91035

Please sign in to comment.