diff --git a/index.js b/index.js index 898ef09..c709843 100644 --- a/index.js +++ b/index.js @@ -180,14 +180,14 @@ function parse(code) { return elements; } -async function recursiveReaddir(rpath, p, fileNames) { +async function recursiveReaddir(rpath, p) { p = p || ''; - fileNames = (fileNames || []).slice(); + let fileNames = []; const files = await fs.readdir(rpath); for (const f of files) { const stat = await fs.lstat(path.join(rpath, f)); if (stat.isDirectory() || stat.isSymbolicLink()) { - fileNames.push(...await recursiveReaddir(path.join(rpath, f), p + f + '/', fileNames)); + fileNames.push(...await recursiveReaddir(path.join(rpath, f), p + f + '/')); } else { fileNames.push(p + f); }