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

feat: custom drivers #11

Merged
merged 8 commits into from
Sep 24, 2020
Merged

feat: custom drivers #11

merged 8 commits into from
Sep 24, 2020

Conversation

lukeed
Copy link
Owner

@lukeed lukeed commented Sep 23, 2020

Allows users to supply custom drivers, so long as they adhere to the Driver interface.

CLI users can use --driver <name> to autoload their driver by name.
Programmatic users can supply opts.driver to any command.

Defining a driver at all skips client auto-detection, since you're telling ley: "here use this thing"

By contrast --client and opts.client is meant to load an internal/off-the-shelf driver.


...Will come back to this. I think client & driver should probably be merged as a single "driver" option.

note: --driver purposefully overrides `exports.driver` from config file
They were basically the same thing. Now just check if the `driver` string matches a supplied driver name. Customize/override by passing a Driver class or a `path/to/file.js` that contains Driver class.
Repository owner deleted a comment from codecov-commenter Sep 23, 2020
@lukeed
Copy link
Owner Author

lukeed commented Sep 23, 2020

OK – decided to merge client and driver options!

Having them separate made for confusing vocabulary, and it didn't really make sense for the internal drivers be kept separate from the rest.

The default behavior doesn't change. The internal drivers are still auto-detected if nothing was passed in to tell ley otherwise.

The one breaking change is that ley --client <name> and opts.client have been removed!
If you previously used either of these, simply use --driver or opts.driver instead with the same value.

Also with this change, --driver and opts.driver can be a filepath (string) to your custom Driver implementation. Or they may be the name of a package (so long as it satisfies the Driver interface). Any string value is passed to require() directly.

Another option to specify a driver is through the ley.config.js file.
You may define a driver key that acts identically as opts.driver for programmatic usage.
Both locations may contain either a string or a Driver class.

The CLI --driver always takes precedence over the other locations.

Copy link
Contributor

@TehShrike TehShrike left a comment

Choose a reason for hiding this comment

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

This looks great! I'm a fan of dropping client.

@lukeed lukeed merged commit b167ca1 into master Sep 24, 2020
@lukeed lukeed deleted the feat/driver branch September 24, 2020 00:11
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