node js builtin os function find

24 Views Asked by At

I'm using the shelljs npm package for file traversal:

var shell = require('shelljs');
cFilesOnly = function (file, idx) { return (file.includes('.c')); }
excludeIrrelevantDir = function (file, idx) { return !file.includes('DDD'); }
var files = shell.find('.').filter(cFilesOnly).filter(excludeIrrelevantDir);
console.log(files);

The package works great:

$ tree
.
├── AAA
│   └── main.c
├── BBB
│   ├── README.md
│   ├── go.c
│   └── run.c
├── DDD
│   └── bad.c
└── main.js

4 directories, 6 files
$ node main.js
[ 'AAA/main.c', 'BBB/go.c', 'BBB/run.c' ]
  • npm reported 1 high severity vulnerability in that package, so
  • I want to replace that package with a native node os alternative.
  • I looked (here) but didn't get very far - what am I missing?
0

There are 0 best solutions below