MCPcopy Index your code
hub / github.com/nodejs/node / grep

Method grep

test/common/wpt.js:483–500  ·  view source on GitHub ↗

* Grep for all .*.js file recursively in a directory. * @param {string} dir * @returns {any[]}

(dir)

Source from the content-addressed store, hash-verified

481 * @returns {any[]}
482 */
483 grep(dir) {
484 let result = [];
485 const list = fs.readdirSync(dir);
486 for (const file of list) {
487 const filepath = path.join(dir, file);
488 const stat = fs.statSync(filepath);
489 if (stat.isDirectory()) {
490 const list = this.grep(filepath);
491 result = result.concat(list);
492 } else {
493 if (!(/\.\w+\.js$/.test(filepath))) {
494 continue;
495 }
496 result.push(filepath);
497 }
498 }
499 return result;
500 }
501
502 load() {
503 const dir = path.join(__dirname, '..', 'wpt');

Callers 1

loadMethod · 0.95

Calls 7

concatMethod · 0.80
readdirSyncMethod · 0.45
joinMethod · 0.45
statSyncMethod · 0.45
isDirectoryMethod · 0.45
testMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected