Description
If you want to use Lebab in your project, you'll likely want to run it over more than just one file, in which case you'll need to resort to shell scripting. Doing something like the following:
for file in $(find . -name "*.js"); do
lebab $file -o $file
done
Having this functionality built into Lebab is an often requested feature (e.g. see #114). Implementing it poses some challenges however:
- Which files should we look for? Only
*.js
? What about*.jsx
? Maybe we'll need an option for that. - Should we also look into hidden directories? Perhaps another option.
- Should we also follow symlinks? Maybe yet another option.
- Transforming lots of files could take time. Maybe we should log some feedback messages?
I think the important part is to make it easy to use Lebab for the most common use case (transforming a directory of *.js files). The special cases could be covered with external scripting like currently.
To keep lebab easily scriptable, the following should still work:
$ cat foo.js | lebab > out.js
$ lebab foo.js > out.js
$ lebab foo.js -o out.js
It also means, that this should not work:
$ lebab scripts/
Instead, there should be a separate option that would communicate the destructive nature of the operation:
$ lebab --replace scripts/
$ lebab --replace script.js
$ lebab --replace 'scripts/*.jsx'