Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Ms2ger
Copy link

@Ms2ger Ms2ger commented Aug 23, 2024

@Ms2ger Ms2ger mentioned this pull request Aug 23, 2024
@Ms2ger Ms2ger marked this pull request as draft August 26, 2024 13:37
@Ms2ger Ms2ger marked this pull request as ready for review August 26, 2024 15:49
Copy link
Contributor

@gibson042 gibson042 left a 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]);
Copy link
Contributor

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

Comment on lines +21 to 29
async evalScript(code, options = {}) {
if (options.module) {
if (!options.testHostArgs) {
options.testHostArgs = [];
}
options.testHostArgs.push('--module');
}

return super.evalScript(code, options);
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants