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

How to filter input by extension ? #530

Open
tolotrasamuel opened this issue May 22, 2021 · 3 comments
Open

How to filter input by extension ? #530

tolotrasamuel opened this issue May 22, 2021 · 3 comments

Comments

@tolotrasamuel
Copy link

The buildExtensions in builder.dart is .dart

It builds for any dart file

buildExtensions = { '.dart': [generatedExtension]..addAll(additionalOutputExtensions) },

Screenshot 2021-05-22 at 12 48 00

So even if in build.yaml, I set the build input to .source.dart

  functionUnwrap:
    import: 'package:my_generators/my_generators.dart'
    builder_factories: ['functionUnwrapBuild']
    auto_apply: dependents
    build_extensions: {".source.dart": [".unwrapped.dart"]}
    build_to: source
    applies_builders: ["source_gen"]

It ignores the ".source.dart" and still runs on any dart file.

@jakemac53
Copy link
Contributor

This package would need to add a named argument to support setting the input extension. Note that for technical reasons we don't validate the extensions match in the build.yaml and the code (they are used for different things and at different stages). The one you put in code is what determines the true inputs though.

We do validate it if you run the doctor command but I believe that is the only time.

@oliatienza
Copy link

This package would need to add a named argument to support setting the input extension. Note that for technical reasons we don't validate the extensions match in the build.yaml and the code (they are used for different things and at different stages). The one you put in code is what determines the true inputs though.

We do validate it if you run the doctor command but I believe that is the only time.

Hi @jakemac53 , can you provide an example on how to do this? Sorry I don't quite get what you mean by "The one you put in code is what determines the true inputs". I'm dealing with the same issue I want to strictly only consider dart files ending with .graphql.dart

@jakemac53
Copy link
Contributor

All Builder classes must express their build extensions both in the build.yaml as well in their buildExtensions getter.

The source_gen package sets the buildExtensions for you, and lets you override the output extension using the generatedExtension parameter, but does not allow you to override the input extension. It would need a similar inputExtension parameter or something to allow you to change it from just .dart.

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

No branches or pull requests

3 participants