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>
This commit is contained in:
parent
041424f87c
commit
09a5f0252e
@ -226,29 +226,6 @@ Object.defineProperty(process, 'argv0', {
|
|||||||
});
|
});
|
||||||
process.argv[0] = process.execPath;
|
process.argv[0] = process.execPath;
|
||||||
|
|
||||||
const { deprecate } = NativeModule.require('internal/util');
|
|
||||||
{
|
|
||||||
// Install legacy getters on the `util` binding for typechecking.
|
|
||||||
// TODO(addaleax): Turn into a full runtime deprecation.
|
|
||||||
const pendingDeprecation = getOptionValue('--pending-deprecation');
|
|
||||||
const utilBinding = internalBinding('util');
|
|
||||||
const types = NativeModule.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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// process.allowedNodeEnvironmentFlags
|
// process.allowedNodeEnvironmentFlags
|
||||||
Object.defineProperty(process, 'allowedNodeEnvironmentFlags', {
|
Object.defineProperty(process, 'allowedNodeEnvironmentFlags', {
|
||||||
get() {
|
get() {
|
||||||
@ -269,6 +246,8 @@ Object.defineProperty(process, 'allowedNodeEnvironmentFlags', {
|
|||||||
enumerable: true,
|
enumerable: true,
|
||||||
configurable: true
|
configurable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { deprecate } = NativeModule.require('internal/util');
|
||||||
// process.assert
|
// process.assert
|
||||||
process.assert = deprecate(
|
process.assert = deprecate(
|
||||||
perThreadSetup.assert,
|
perThreadSetup.assert,
|
||||||
|
@ -2,6 +2,45 @@
|
|||||||
|
|
||||||
const { getOptionValue } = require('internal/options');
|
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() {
|
function initializeClusterIPC() {
|
||||||
// If this is a worker in cluster mode, start up the communication
|
// If this is a worker in cluster mode, start up the communication
|
||||||
// channel. This needs to be done before any user code gets executed
|
// channel. This needs to be done before any user code gets executed
|
||||||
@ -75,6 +114,7 @@ function loadPreloadModules() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializePolicy,
|
initializePolicy,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// instead of actually running the file.
|
// instead of actually running the file.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializePolicy,
|
initializePolicy,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
@ -21,6 +22,7 @@ const {
|
|||||||
} = require('internal/modules/cjs/helpers');
|
} = require('internal/modules/cjs/helpers');
|
||||||
|
|
||||||
// TODO(joyeecheung): not every one of these are necessary
|
// TODO(joyeecheung): not every one of these are necessary
|
||||||
|
initializeDeprecations();
|
||||||
initializeClusterIPC();
|
initializeClusterIPC();
|
||||||
initializePolicy();
|
initializePolicy();
|
||||||
initializeESMLoader();
|
initializeESMLoader();
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Stdin is not a TTY, we will read it and execute it.
|
// Stdin is not a TTY, we will read it and execute it.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializePolicy,
|
initializePolicy,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
@ -14,6 +15,7 @@ const {
|
|||||||
readStdin
|
readStdin
|
||||||
} = require('internal/process/execution');
|
} = require('internal/process/execution');
|
||||||
|
|
||||||
|
initializeDeprecations();
|
||||||
initializeClusterIPC();
|
initializeClusterIPC();
|
||||||
initializePolicy();
|
initializePolicy();
|
||||||
initializeESMLoader();
|
initializeESMLoader();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// `--interactive`.
|
// `--interactive`.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializePolicy,
|
initializePolicy,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
@ -13,6 +14,7 @@ const { evalScript } = require('internal/process/execution');
|
|||||||
const { addBuiltinLibsToObject } = require('internal/modules/cjs/helpers');
|
const { addBuiltinLibsToObject } = require('internal/modules/cjs/helpers');
|
||||||
|
|
||||||
const source = require('internal/options').getOptionValue('--eval');
|
const source = require('internal/options').getOptionValue('--eval');
|
||||||
|
initializeDeprecations();
|
||||||
initializeClusterIPC();
|
initializeClusterIPC();
|
||||||
initializePolicy();
|
initializePolicy();
|
||||||
initializeESMLoader();
|
initializeESMLoader();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// the main module is not specified and stdin is a TTY.
|
// the main module is not specified and stdin is a TTY.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializePolicy,
|
initializePolicy,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
@ -14,6 +15,7 @@ const {
|
|||||||
evalScript
|
evalScript
|
||||||
} = require('internal/process/execution');
|
} = require('internal/process/execution');
|
||||||
|
|
||||||
|
initializeDeprecations();
|
||||||
initializeClusterIPC();
|
initializeClusterIPC();
|
||||||
initializePolicy();
|
initializePolicy();
|
||||||
initializeESMLoader();
|
initializeESMLoader();
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializePolicy,
|
initializePolicy,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
loadPreloadModules
|
loadPreloadModules
|
||||||
} = require('internal/bootstrap/pre_execution');
|
} = require('internal/bootstrap/pre_execution');
|
||||||
|
|
||||||
|
initializeDeprecations();
|
||||||
initializeClusterIPC();
|
initializeClusterIPC();
|
||||||
initializePolicy();
|
initializePolicy();
|
||||||
initializeESMLoader();
|
initializeESMLoader();
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// message port.
|
// message port.
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
initializeDeprecations,
|
||||||
initializeClusterIPC,
|
initializeClusterIPC,
|
||||||
initializeESMLoader,
|
initializeESMLoader,
|
||||||
loadPreloadModules
|
loadPreloadModules
|
||||||
@ -55,6 +56,7 @@ port.on('message', (message) => {
|
|||||||
if (manifestSrc) {
|
if (manifestSrc) {
|
||||||
require('internal/process/policy').setup(manifestSrc, manifestURL);
|
require('internal/process/policy').setup(manifestSrc, manifestURL);
|
||||||
}
|
}
|
||||||
|
initializeDeprecations();
|
||||||
initializeClusterIPC();
|
initializeClusterIPC();
|
||||||
initializeESMLoader();
|
initializeESMLoader();
|
||||||
loadPreloadModules();
|
loadPreloadModules();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user