summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/pre_execution.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-01-31 03:08:25 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2019-02-08 08:08:48 +0800
commit09a5f0252ed8e367dd29ba77e2931e5cf2a39a9e (patch)
tree137d43029fab008be5d06adb6a61da4d3383228c /lib/internal/bootstrap/pre_execution.js
parent041424f87cf7cb75e6b509e86411fa833c4c2dd8 (diff)
downloadandroid-node-v8-09a5f0252ed8e367dd29ba77e2931e5cf2a39a9e.tar.gz
android-node-v8-09a5f0252ed8e367dd29ba77e2931e5cf2a39a9e.tar.bz2
android-node-v8-09a5f0252ed8e367dd29ba77e2931e5cf2a39a9e.zip
process: move deprecation warning initialization into pre_execution.js
Since this is only necessary when user code execution is expected. PR-URL: https://github.com/nodejs/node/pull/25825 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r--lib/internal/bootstrap/pre_execution.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index 798c581a72..d09fdb131a 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -2,6 +2,45 @@
const { getOptionValue } = require('internal/options');
+// In general deprecations are intialized wherever the APIs are implemented,
+// this is used to deprecate APIs implemented in C++ where the deprecation
+// utitlities are not easily accessible.
+function initializeDeprecations() {
+ const { deprecate } = require('internal/util');
+ const pendingDeprecation = getOptionValue('--pending-deprecation');
+
+ // DEP0103: access to `process.binding('util').isX` type checkers
+ // TODO(addaleax): Turn into a full runtime deprecation.
+ const utilBinding = internalBinding('util');
+ const types = require('internal/util/types');
+ for (const name of [
+ 'isArrayBuffer',
+ 'isArrayBufferView',
+ 'isAsyncFunction',
+ 'isDataView',
+ 'isDate',
+ 'isExternal',
+ 'isMap',
+ 'isMapIterator',
+ 'isNativeError',
+ 'isPromise',
+ 'isRegExp',
+ 'isSet',
+ 'isSetIterator',
+ 'isTypedArray',
+ 'isUint8Array',
+ 'isAnyArrayBuffer'
+ ]) {
+ utilBinding[name] = pendingDeprecation ?
+ deprecate(types[name],
+ 'Accessing native typechecking bindings of Node ' +
+ 'directly is deprecated. ' +
+ `Please use \`util.types.${name}\` instead.`,
+ 'DEP0103') :
+ types[name];
+ }
+}
+
function initializeClusterIPC() {
// If this is a worker in cluster mode, start up the communication
// channel. This needs to be done before any user code gets executed
@@ -75,6 +114,7 @@ function loadPreloadModules() {
}
module.exports = {
+ initializeDeprecations,
initializeClusterIPC,
initializePolicy,
initializeESMLoader,