diff --git a/src/node.js b/src/node.js index 065c337e743993..4becfa978d5e12 100644 --- a/src/node.js +++ b/src/node.js @@ -159,8 +159,28 @@ startup.globalVariables = function() { global.process = process; global.global = global; - global.GLOBAL = global; - global.root = global; + + // Deprecate GLOBAL and root + ['GLOBAL', 'root'].forEach(function (name) { + // getter + const get = NativeModule.require('util').deprecate(function() { + const desc = { configurable: true, enumerable: true, value: this }; + Object.defineProperty(this, 'GLOBAL', desc); + return this; + }, "'" + name + "' is deprecated, use 'global'"); + // setter + const set = function(value) { + const desc = { configurable: true, enumerable: true, value: value }; + Object.defineProperty(this, name, desc); + }; + // define property + Object.defineProperty(global, name, { + configurable: true, // but not enumerable + get: get, + set: set + }); + }); + global.Buffer = NativeModule.require('buffer').Buffer; process.domain = null; process._exiting = false;