shelljs / shelljs/shelljs

find() should work like find(1)

Open
#114 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bash compat fix help wanted low priority
Dominant language
JavaScript
Stars
14.4k
Forks
756
PR merge metrics
No 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the sh.find API entry point referenced in the issue and inspect how its current path matching works. Compare the requested find('*/package.json') behavior with the documented find interface, then verify that matching package files produces the expected directory paths and that existing behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.