-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Export yargs options and check function for consumption by wrapper modules #4122
Conversation
👋🏻 Just wanted to check in on this to see if it can be merged, would be a huge help to some changes needed on our end. Thanks! |
Would love to see this merged as it would be a great boon to https://github.com/sysgears/mochapack/. |
Wouldn't it make sense to get this feature into mocha? |
Incorporated latest changes from Mocha's master branch before resolving the conflict in current version of |
@Jack-Barry I don't know wether this PR makes sense or not. |
@juergba Apologies for the messiness, I am still new to contributing to other peoples' projects and using Git features such as rebase. I have tried to clean up this PR as you suggested. I also added another change we'd need to make this a little better on our end to be able to use Mocha's If there is another way that Mocha can be initiated from a tool that wraps it in their own CLI aside from having to re-implement all of the Yargs options, I'm open to that alternative path. Otherwise, this is the best way we could come up with to allow our project to minimize re-implementing features already written in the Mocha codebase. It allows us to parse Mocha-targeted args with a simpler implementation like this: import { options, check } from 'mocha/lib/cli/run'
import { aliases, types } from 'mocha/lib/cli/run-option-metadata'
export const parseMochaArgs = (argv) =>
yargs
.options(options)
.check(check(yargs))
.alias(aliases)
.array(types.array)
.boolean(types.boolean)
.string(types.string)
.number(types.number)
.parse(argv) As opposed to re-implementing all of the |
This PR hasn't had any recent activity, and I'm labeling it |
Description of the Change
Exports the Yargs
options
andcheck
function thatmocha
uses to allow wrapper modules to consume them. This is accomplished by assigning theoptions
to an exportable object and the exporting thecheck
function before they are used bymocha
internally.Alternate Designs
Without exporting the
options
andcheck
, wrapper modules are stuck re-implementing theoptions
andcheck
themselves, which stinks 💩Why should this be in core?
This would provide external modules what they need to avoid reinventing the wheel, and doesn't break or disrupt anything here.
Benefits
Allows us to implement a fix for this
Possible Drawbacks
I can't think of any.
Applicable issues
Aforementioned issue