-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass the --module argument to the SM shell in the expected location #141
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm suggesting an alternate approach that doesn't introduce a new option.
@@ -212,7 +212,7 @@ class ConsoleAgent extends Agent { | |||
}; | |||
} | |||
|
|||
this[CHILD_PROCESS] = await this.createChildProcess([tempfile]); | |||
this[CHILD_PROCESS] = await this.createChildProcess([...options.testHostArgs || [], tempfile]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this[CHILD_PROCESS] = await this.createChildProcess([...options.testHostArgs || [], tempfile]); | |
this[CHILD_PROCESS] = await this.createChildProcess([tempfile], options); |
async evalScript(code, options = {}) { | ||
if (options.module) { | ||
if (!options.testHostArgs) { | ||
options.testHostArgs = []; | ||
} | ||
options.testHostArgs.push('--module'); | ||
} | ||
|
||
return super.evalScript(code, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than mutating options, I think I'd rather have this class override ConsoleAgent createChildProcess
(which incidentally removes the need to override evalScript
).
async evalScript(code, options = {}) { | |
if (options.module) { | |
if (!options.testHostArgs) { | |
options.testHostArgs = []; | |
} | |
options.testHostArgs.push('--module'); | |
} | |
return super.evalScript(code, options); | |
async createChildProcess(args = [], options = {}) { | |
if (options.module) { | |
args = ['--module', ...args]; | |
} | |
return super.createChildProcess(args, options); |
Ref tc39/test262-harness#163