You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
599 B
22 lines
599 B
const { readdirSync } = require("../compat/fs");
|
|
const { init, walkSingleDir, readdirOpts } = require("./shared");
|
|
|
|
function sync(dirPath, options) {
|
|
const { state, callbackInvoker, dir } = init(dirPath, options, null, true);
|
|
walk(state, dir, options.maxDepth);
|
|
return callbackInvoker(state);
|
|
}
|
|
|
|
function walk(state, dir, currentDepth) {
|
|
if (currentDepth < 0) {
|
|
return;
|
|
}
|
|
try {
|
|
const dirents = readdirSync(dir, readdirOpts);
|
|
walkSingleDir(walk, state, dir, dirents, currentDepth);
|
|
} catch (e) {
|
|
if (!state.options.suppressErrors) throw e;
|
|
}
|
|
}
|
|
|
|
module.exports = sync;
|
|
|