|
23 | 23 |
|
24 | 24 | const{ |
25 | 25 | ArrayPrototypeForEach, |
| 26 | + ArrayPrototypeUnshift, |
26 | 27 | Symbol, |
27 | 28 | PromiseReject, |
28 | 29 | ReflectApply, |
@@ -130,17 +131,17 @@ class Script extends ContextifyScript { |
130 | 131 | if(breakOnSigint&&process.listenerCount('SIGINT')>0){ |
131 | 132 | returnsigintHandlersWrap(super.runInThisContext,this,args); |
132 | 133 | } |
133 | | -returnsuper.runInThisContext(...args); |
| 134 | +returnReflectApply(super.runInThisContext,this,args); |
134 | 135 | } |
135 | 136 |
|
136 | 137 | runInContext(contextifiedObject,options){ |
137 | 138 | validateContext(contextifiedObject); |
138 | 139 | const{ breakOnSigint, args }=getRunInContextArgs(options); |
| 140 | +ArrayPrototypeUnshift(args,contextifiedObject); |
139 | 141 | if(breakOnSigint&&process.listenerCount('SIGINT')>0){ |
140 | | -returnsigintHandlersWrap(super.runInContext,this, |
141 | | -[contextifiedObject, ...args]); |
| 142 | +returnsigintHandlersWrap(super.runInContext,this,args); |
142 | 143 | } |
143 | | -returnsuper.runInContext(contextifiedObject, ...args); |
| 144 | +returnReflectApply(super.runInContext,this,args); |
144 | 145 | } |
145 | 146 |
|
146 | 147 | runInNewContext(contextObject,options){ |
@@ -274,9 +275,9 @@ function sigintHandlersWrap(fn, thisArg, argsArray) { |
274 | 275 | }finally{ |
275 | 276 | // Add using the public methods so that the `newListener` handler of |
276 | 277 | // process can re-attach the listeners. |
277 | | -for(constlistenerofsigintListeners){ |
| 278 | +ArrayPrototypeForEach(sigintListeners,(listener)=>{ |
278 | 279 | process.addListener('SIGINT',listener); |
279 | | -} |
| 280 | +}); |
280 | 281 | } |
281 | 282 | } |
282 | 283 |
|
|
0 commit comments