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).
A stronger filtering system for commands accepting glob patterns as input (
copy
,update
,remove
,write
) can be particularly useful, specifically combined withfrom file
. For example the following would allow adding license headers to all files lacking a license header: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).