Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

feat(options): Allow include to be an object #299

Merged
merged 3 commits into from
Aug 3, 2021

Conversation

lobsterkatie
Copy link
Member

This mirrors the change in getsentry/sentry-cli#1001, which allows for path-specific options to be passed as part of the include option value. Specifically, this:

  • Fixes normalization of the include option to account for the new possibility of it being an object, and of the ignore option within that object
  • Adds tests for the normalization
  • Updates the README to reflect the new possibility
  • Fixes a bug in the normalization function toArray() so that falsy (but defined) values aren't ignored. We don't actually ever use it in a way which would make this an issue, but it seemed silly to leave the bug in place when the fix was so simple.

@lobsterkatie lobsterkatie merged commit 9bb9448 into master Aug 3, 2021
@lobsterkatie lobsterkatie deleted the kmclb-allow-include-to-be-an-object branch August 3, 2021 17:34
lobsterkatie added a commit that referenced this pull request Aug 5, 2021
…pes (#302)

There are three places where this plugin is more permissive in its option types than its underlying `@sentry/cli` dependency:

- `include` option: Can be given as a single path (either in string or descriptor object form) here, but must be an array for `@sentry/cli`

- `ignore` option: Can be given as a single path (a string) here, but must be an array for `@sentry/cli`

- `ignore` option in `include` descriptor object: Can be given as a single path (a string) here, but must be an array for `@sentry/cli`

In other words, any of the following would. be fine for this plugin, but none would be okay for `@sentry/cli`:

```
const options = {
  include: "This needs to be wrapped in an array",
  ignore: "So does this",
};

const differentOptions = {
  include: { paths: ["This whole object needs to be wrapped in an array"] },
};

const evenMoreOptions = {
  include: [
    {
      paths: ["This overall `include` option is fine"],
      ignore: "But this `ignore` option needs wrapping",
    },
  ],
};
```

To compensate for this, we normalize the plugin options, fixing each of the problems detailed in the example, before we pass them to `@sentry/cli`. At least, that's what we're supposed to do. The possible problems and combinations of problems got more complicated when descriptor object `include` values were introduced in #299, and some of them were overlooked. This should fix that problem, as well as expand the tests to cover all scenarios.

There also is currently a (related) problem with our types, which predates the aforementioned PR. In the types file here, we've been inheriting the `include` and `ignore` types from `@sentry/cli`, even though those types are (theoretically) more permissive here than they are there. This also fixes that problem, redefining those types to include the looser options.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants