-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
util: introduce
printDeprecationMessage
function
`printDeprecationMessage` is used to deprecate modules and execution branches. PR-URL: #1822 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Loading branch information
1 parent
6537fd4
commit 628845b
Showing
5 changed files
with
26 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
exports.printDeprecationMessage = function(msg, warned) { | ||
if (process.noDeprecation) | ||
return true; | ||
|
||
if (warned) | ||
return warned; | ||
|
||
if (process.throwDeprecation) | ||
throw new Error(msg); | ||
else if (process.traceDeprecation) | ||
console.trace(msg); | ||
else | ||
console.error(msg); | ||
|
||
return true; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
'use strict'; | ||
|
||
const util = require('util'); | ||
const util = require('internal/util'); | ||
|
||
// the sys module was renamed to 'util'. | ||
// this shim remains to keep old programs working. | ||
// sys is deprecated and shouldn't be used | ||
|
||
const setExports = util.deprecate(function() { | ||
module.exports = util; | ||
}, 'sys is deprecated. Use util instead.'); | ||
|
||
setExports(); | ||
module.exports = require('util'); | ||
util.printDeprecationMessage('sys is deprecated. Use util instead.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters