summaryrefslogtreecommitdiff
path: root/lib/internal/bootstrap/pre_execution.js
diff options
context:
space:
mode:
authorGuy Bedford <guybedford@gmail.com>2019-03-24 01:00:07 +0200
committerGuy Bedford <guybedford@gmail.com>2019-03-26 15:26:07 +0200
commit53ebd3311d4e0ef184a062b2f657ac69dc8a7acf (patch)
treec4c02f88528daa2be9d920968e80cca40b79b48b /lib/internal/bootstrap/pre_execution.js
parent2d5387e143255d97210b25280df1addb7f5ccb34 (diff)
downloadandroid-node-v8-53ebd3311d4e0ef184a062b2f657ac69dc8a7acf.tar.gz
android-node-v8-53ebd3311d4e0ef184a062b2f657ac69dc8a7acf.tar.bz2
android-node-v8-53ebd3311d4e0ef184a062b2f657ac69dc8a7acf.zip
process: global.process, global.Buffer getters
PR-URL: https://github.com/nodejs/node/pull/26882 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/internal/bootstrap/pre_execution.js')
-rw-r--r--lib/internal/bootstrap/pre_execution.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js
index c38822bd89..233ab4f879 100644
--- a/lib/internal/bootstrap/pre_execution.js
+++ b/lib/internal/bootstrap/pre_execution.js
@@ -1,6 +1,7 @@
'use strict';
const { getOptionValue } = require('internal/options');
+const { Buffer } = require('buffer');
function prepareMainThreadExecution() {
// Patch the process object with legacy properties and normalizations
@@ -221,6 +222,33 @@ function initializeDeprecations() {
'process.binding() is deprecated. ' +
'Please use public APIs instead.', 'DEP0111');
}
+
+ // Create global.process and global.Buffer as getters so that we have a
+ // deprecation path for these in ES Modules.
+ // See https://github.com/nodejs/node/pull/26334.
+ let _process = process;
+ Object.defineProperty(global, 'process', {
+ get() {
+ return _process;
+ },
+ set(value) {
+ _process = value;
+ },
+ enumerable: false,
+ configurable: true
+ });
+
+ let _Buffer = Buffer;
+ Object.defineProperty(global, 'Buffer', {
+ get() {
+ return _Buffer;
+ },
+ set(value) {
+ _Buffer = value;
+ },
+ enumerable: false,
+ configurable: true
+ });
}
function setupChildProcessIpcChannel() {