|
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 | return sigintHandlersWrap(super.runInThisContext, this, args);
|
132 | 133 | }
|
133 |
| - return super.runInThisContext(...args); |
| 134 | + return ReflectApply(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 |
| - return sigintHandlersWrap(super.runInContext, this, |
141 |
| - [contextifiedObject, ...args]); |
| 142 | + return sigintHandlersWrap(super.runInContext, this, args); |
142 | 143 | }
|
143 |
| - return super.runInContext(contextifiedObject, ...args); |
| 144 | + return ReflectApply(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 (const listener of sigintListeners) { |
| 278 | + ArrayPrototypeForEach(sigintListeners, (listener) => { |
278 | 279 | process.addListener('SIGINT', listener);
|
279 |
| - } |
| 280 | + }); |
280 | 281 | }
|
281 | 282 | }
|
282 | 283 |
|
|
0 commit comments