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

Add filtering to commands operating on multiple files. #24

Open
loreanvictor opened this issue Jul 31, 2023 · 0 comments
Open

Add filtering to commands operating on multiple files. #24

loreanvictor opened this issue Jul 31, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@loreanvictor
Copy link
Owner

loreanvictor commented Jul 31, 2023

A stronger filtering system for commands accepting glob patterns as input (copy, update, remove, write) can be particularly useful, specifically combined with from file. For example the following would allow adding license headers to all files lacking a license header:

steps:
  - read: license
    from file: license-header

  - write: '{{ license }}\n{{ __content__ }}'
    to: '**/*.(jsx?|tsx?|cpp|java)'
    where:
      steps:
        - read: __content__
          from file: __file__
      eval: '{{ __content__ | not matches: /^\s*\/\*\*\s*\*\s*\@license/ }}'

This would require setting a loop variable __file__, which would be the address (absolute?) of the file. I think for cleanliness, it should be unset after the loop is executed. A cleaner solution would be to create a loop-specific scope (the parser would need to do this, but it would be relatively straightforward).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant