shelljs/shelljs

find() should work like find(1)

Open

#114 opened on Apr 4, 2014

View on GitHub
 (1 comment) (0 reactions) (0 assignees)JavaScript (777 forks)batch import
bash compatfixhelp wantedlow priority

Repository metrics

Stars
 (14,062 stars)
PR merge metrics
 (Avg merge 3d 12h) (2 merged PRs in 30d)

Description

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).

Contributor guide