Files
react.dev/scripts/headingIDHelpers/walk.js
Lauren Tan 68fece54b3 Update copyright on all files
Run the script.
2025-09-18 12:39:04 -04:00

32 lines
745 B
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const fs = require('fs');
module.exports = function walk(dir) {
let results = [];
/**
* If the param is a directory we can return the file
*/
if (dir.includes('md')) {
return [dir];
}
const list = fs.readdirSync(dir);
list.forEach(function (file) {
file = dir + '/' + file;
const stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
/* Recurse into a subdirectory */
results = results.concat(walk(file));
} else {
/* Is a file */
results.push(file);
}
});
return results;
};