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' ]