shelljs / shx

Portable Shell Commands for Node
MIT License
1.72k stars 44 forks source link

find not fully supported #177

Open tdjastrzebski opened 4 years ago

tdjastrzebski commented 4 years ago

I just made the first attempt to use shx. shx find BUILD/debug -type f -name '*.o' yields find: no such file or directory: -type

nfischer commented 4 years ago

This is a known limitation of ShellJS's find() method. First step would be supporting the -type flag over there. I think shx could translate "-name" to shelljs's expected syntax, similar to how we translate sed's syntax:

https://github.com/shelljs/shx/blob/7e7bf7fe136c923ab6abbc39406fb87444aaf16d/src/shx.js#L95-L100

tdjastrzebski commented 4 years ago

It looks -name flag is not fully supported as well. shx find BUILD/debug -name '*.o' results in find: no such file or directory: -name

nfischer commented 4 years ago

-name is just the default argument. Try cd BUILD/debug && shx find '**/*.o'.

tdjastrzebski commented 4 years ago

Well, yes, of course. The point, however, is still valid. -name flag is not supported.

nfischer commented 4 years ago

My point above was that we could probably translate that within shx itself (merge default arg + -name into shelljs's expected input). But there's little point for doing so right now because shell.find() is just a wrapper around shell.ls() (you could just use shx ls for the same effect). If we implement -type, then shell.find() would bring something valuable to the table.

carlocorradini commented 1 year ago

Any update on this? Thanks 😥

carlocorradini commented 1 year ago

Sorry for bothering you, but does the following work?

npx shx find "scripts/**/*.sh" -exec npx shellcheck {} \;

Or there is another (supported) approach? Thanks