File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 159159 startup . globalVariables = function ( ) {
160160 global . process = process ;
161161 global . global = global ;
162- global . GLOBAL = global ;
163- global . root = global ;
162+
163+ // Deprecate GLOBAL and root
164+ [ 'GLOBAL' , 'root' ] . forEach ( function ( name ) {
165+ // getter
166+ const get = NativeModule . require ( 'util' ) . deprecate ( function ( ) {
167+ const desc = { configurable : true , enumerable : true , value : this } ;
168+ Object . defineProperty ( this , 'GLOBAL' , desc ) ;
169+ return this ;
170+ } , "'" + name + "' is deprecated, use 'global'" ) ;
171+ // setter
172+ const set = function ( value ) {
173+ const desc = { configurable : true , enumerable : true , value : value } ;
174+ Object . defineProperty ( this , name , desc ) ;
175+ } ;
176+ // define property
177+ Object . defineProperty ( global , name , {
178+ configurable : true , // but not enumerable
179+ get : get ,
180+ set : set
181+ } ) ;
182+ } ) ;
183+
164184 global . Buffer = NativeModule . require ( 'buffer' ) . Buffer ;
165185 process . domain = null ;
166186 process . _exiting = false ;
You can’t perform that action at this time.
0 commit comments