JavaScript Snippet – Recurse A Directory Synchronously

Recently I took a look at making HTML5 programs that will work on Mac, Linux and Windows via Electron and needed a way to recurse a directory synchronously in Node.js. I ended up with the following code:

The above function allows us to recursively get the contents of a directory. It also provides the ability to filter out files and sub-directories. The following is an example of using it to simply get all files and directories within a specified directory:

Related Posts

Here is how you install Watchtower Library on Mac: Either insert the Watchtower Library disc or if you have the Watchtower Library setup files in a folder make sure you can find it. Download Wineskin Read more…