Created
November 3, 2016 05:20
-
-
Save Isaddo/13855725e251993a9dde0d183587280a to your computer and use it in GitHub Desktop.
Get all file paths in a directory recursively
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 path = require('path') | |
const fs = require('fs') | |
function walkDirSync (dir) { | |
return fs.readdirSync(dir).reduce((filePaths, fileName) => { | |
const filePath = path.join(dir, fileName) | |
if (fs.statSync(filePath).isDirectory()) { | |
return filePaths.concat(walkDirSync(filePath)) | |
} | |
return filePaths.concat(filePath) | |
}, []) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment