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

find() should work like find(1) #114

Open
ritch opened this Issue Apr 4, 2014 · 1 comment

Comments

Projects
None yet
3 participants
@ritch

ritch commented Apr 4, 2014

I expected the following to work... but took a look at the docs and require('shelljs').find quite a bit different than I expected.

Here is what I'm trying to do:

// find all directories in the cwd that have a package.json
var sh = require('shelljs');
var packages = sh.find('*/package.json').map((f) => {
 return path.dirname(f)
}); 

This is obviously not possible with sh.find. You have to do something like

sh.find('.').filter((p) => {
  return path.dirname(p) === cwd
      && path.filename(p) === 'package.json'
});

Would be nice if it supported the same functionality as find(1).

@joshi-sh

This comment has been minimized.

Contributor

joshi-sh commented May 13, 2018

The parameter to find is a path, not a pattern. This functionality should be provided via the -name parameter instead, see https://www.gnu.org/software/findutils/manual/html_mono/find.html#Base-Name-Patterns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment