File tree Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Expand file tree Collapse file tree 3 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 77
88'use strict' ;
99
10- ( function ( process ) {
10+ ( function ( global , process ) {
11+
12+ function startup ( global , process ) {
13+ // Expose the global object as a property on itself
14+ // (Allows you to set stuff on `global` from anywhere in JavaScript.)
15+ global . global = global ;
1116
12- function startup ( ) {
1317 const EventEmitter = NativeModule . require ( 'events' ) ;
1418 process . _eventsCount = 0 ;
1519
196200 enumerable : false ,
197201 configurable : true
198202 } ) ;
199- global . process = process ;
203+ Object . defineProperty ( global , 'process' , {
204+ value : process ,
205+ writable : false ,
206+ enumerable : true ,
207+ configurable : true
208+ } ) ;
200209 const util = NativeModule . require ( 'util' ) ;
201210
202211 // Deprecate GLOBAL and root
532541 NativeModule . _cache [ this . id ] = this ;
533542 } ;
534543
535- startup ( ) ;
544+ startup ( global , process ) ;
536545} ) ;
Original file line number Diff line number Diff line change @@ -3441,19 +3441,15 @@ void LoadEnvironment(Environment* env) {
34413441
34423442 env->SetMethod (env->process_object (), " _rawDebug" , RawDebug);
34433443
3444- // Expose the global object as a property on itself
3445- // (Allows you to set stuff on `global` from anywhere in JavaScript.)
3446- global->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " global" ), global);
3447-
34483444 // Now we call 'f' with the 'process' variable that we've built up with
34493445 // all our bindings. Inside bootstrap_node.js and internal/process we'll
34503446 // take care of assigning things to their places.
34513447
34523448 // We start the process this way in order to be more modular. Developers
34533449 // who do not like how bootstrap_node.js sets up the module system but do
34543450 // like Node's I/O bindings may want to replace 'f' with their own function.
3455- Local<Value> arg = env->process_object ();
3456- f->Call (Null (env->isolate ()), 1 , &arg );
3451+ Local<Value> argv[] = { global, env->process_object () } ;
3452+ f->Call (Null (env->isolate ()), arraysize (argv), argv );
34573453}
34583454
34593455static void PrintHelp () {
Original file line number Diff line number Diff line change 11/* eslint-disable no-global-assign */
2- /* eslint-disable required-modules */
32'use strict' ;
43
5- process = null ; // Should not bring down program.
4+ require ( '../common' ) ;
5+ const assert = require ( 'assert' ) ;
6+
7+ assert . throws ( ( ) => process = null , / C a n n o t a s s i g n t o r e a d o n l y p r o p e r t y / ) ;
You can’t perform that action at this time.
0 commit comments