-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: nodePath & mochaPath #210
base: main
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.
Some remarks on your proposal:
- Did you find out why your change is not working?
- We need some unit/integration test for this feature to ensure it is working as expected.
- I assume these settings should be shared among users via settings.json commited to the repository. This raises some additional concerns about the "path" design:
- For the alternative package to be used we likely want to assume relative paths. We have to clarify from where they are handled relatively.
- Node.js is likely installed somewhere on the system and this cannot be properly shared. It would be incorrect to assume a fixed absolute system path.
- For security reasons it would be likely good to enforce workspace relative paths.
Maybe the following approach could also serve your needs?
Instead of configuring the path to mocha and node we could launch shell/batch scripts with the respective arguments we would pass to mocha. These could be configurable or we simply search for a "mocha.{bat,sh}" in the workspace root if it exists, its used. In this shell script you can then launch any alternative executable and path with the arguments as you like.
const mochaPath = vscode.workspace.getConfiguration('mocha-vscode').get<string>('mochaPath'); | ||
this._pathToMocha = mochaPath || (await this._resolveLocalMochaBinPath()); |
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 change breaks proper caching of the variable and cause re-evaluation on every spawn of mocha. We should keep the caching for the locally resolved path as it can be expensive in some scenarios.
// Check if the nodePath setting is defined | ||
const nodePath = vscode.workspace.getConfiguration('mocha-vscode').get<string>('nodePath'); | ||
if (nodePath) { | ||
logChannel.debug(`Using nodePath from settings: '${nodePath}'`); | ||
return nodePath; | ||
} |
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.
Your issue only talks about redirecting Mocha to anoter tooling. What's the real usecase behind redirecting node as well? Depending on your need also NPM would need support for reconfiguration.
closes #209
This pull request adds settings for both
mochaPath
andnodePath
. I was hoping this would help me to getelectron-mocha
working with this extension, but simply swapping outelectron-mocha
formocha
doesn't seem to do it.Nonetheless, here's a PR of my changes.
And here's the robot has to say about it:
This pull request introduces new configuration options for specifying the paths to the Mocha and Node.js executables, and updates the code to utilize these configurations. The changes enhance the flexibility of the extension by allowing users to specify custom paths for these executables.
New configuration options:
README.md
: Added descriptions formocha-vscode.mochaPath
andmocha-vscode.nodePath
settings, which specify the paths to the Mocha and Node.js executables, respectively.package.json
: Addedmocha-vscode.mochaPath
andmocha-vscode.nodePath
settings to the configuration schema.Code updates to use new configurations:
src/configurationFile.ts
: UpdatedgetMochaSpawnArgs
method to use themochaPath
setting if defined, falling back to resolving the local Mocha binary path if not.src/node.ts
: UpdatedgetPathToNode
function to use thenodePath
setting if defined, logging the path being used.