Created
October 19, 2022 08:29
-
-
Save niugm/329af6eade6b2446ea7be540a85d0285 to your computer and use it in GitHub Desktop.
[utils] JavaScript utils functions #javascript #node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs-extra'); | |
const path = require('path'); | |
function readdirSyncRecursive(dir, fileList = []) { | |
const files = fs.readdirSync(dir); | |
files.forEach((file) => { | |
const filePath = path.join(dir, file); | |
if (fs.statSync(filePath).isDirectory()) { | |
readdirSyncRecursive(filePath, fileList); | |
} else { | |
fileList.push(filePath); | |
} | |
}); | |
return fileList; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment