Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ConsoleAgent.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class ConsoleAgent extends Agent {
};
}

this[CHILD_PROCESS] = await this.createChildProcess([tempfile]);
this[CHILD_PROCESS] = await this.createChildProcess([...options.testHostArgs || [], tempfile]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this[CHILD_PROCESS] = await this.createChildProcess([...options.testHostArgs || [], tempfile]);
this[CHILD_PROCESS] = await this.createChildProcess([tempfile], options);

this.hasFinishedCreatingChildProcess = true;

if (this.isStopped && this[CHILD_PROCESS] === null) {
Expand Down
16 changes: 11 additions & 5 deletions lib/agents/jsshell.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,19 @@ const stackRe = /^([\s\S]*?)\r?\nStack:\r?\n([\s\S]*)$/;
const stackFrameRe = /^(.*?)?@(.*?):(\d+):(\d+)?$/;

class JSShell extends ConsoleAgent {
async evalScript(code, options = {}) {
if (options.module && this.args[0] !== '--module') {
this.args.unshift('--module');
constructor(options) {
super(options);
if (this.args.indexOf('--module') !== -1) {
throw new Error("Passing --module as a SpiderMonkey host argument is not supported.")
}
}

if (!options.module && this.args[0] === '--module') {
this.args.shift();
async evalScript(code, options = {}) {
if (options.module) {
if (!options.testHostArgs) {
options.testHostArgs = [];
}
options.testHostArgs.push('--module');
}

return super.evalScript(code, options);
Comment on lines +21 to 29
Copy link
Member

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).

Suggested change
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);

Expand Down